From d9c45dda20a38bd79745db72055849bb2eb287de Mon Sep 17 00:00:00 2001 From: Ian Leonard Date: Sat, 24 Jun 2023 00:21:01 +0000 Subject: [PATCH] updates: only run set_release_channel refresh tasks if it changed Signed-off-by: Ian Leonard --- resources/lib/modules/updates.py | 51 +++++++++++++++++--------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/resources/lib/modules/updates.py b/resources/lib/modules/updates.py index bf52eb40c..dbcb87a3e 100644 --- a/resources/lib/modules/updates.py +++ b/resources/lib/modules/updates.py @@ -289,36 +289,39 @@ def set_value(self, listItem): @log.log_function() def set_release_channel(self, listItem): - if listItem: - self.set_value(listItem) + if 'value' in self.struct['update']['settings']['ReleaseChannel']: + old_release_channel = self.struct['update']['settings']['ReleaseChannel']['value'] + self.set_value(listItem) release_channel = self.struct['update']['settings']['ReleaseChannel']['value'] - # Show or hide menu elements based on selected channel - if release_channel == 'stable': - # Automatic update only on stable releases - if 'hidden' in self.struct['update']['settings']['AutoUpdate']: - del(self.struct['update']['settings']['AutoUpdate']['hidden']) - # Only show manual update options if automatic update disabled - if self.struct['update']['settings']['AutoUpdate']['value'] == '0': + # Only do work if ReleaseChannel changed + if release_channel != old_release_channel: + # Show or hide menu elements based on selected channel + if release_channel == 'stable': + # Automatic update only on stable releases + if 'hidden' in self.struct['update']['settings']['AutoUpdate']: + del(self.struct['update']['settings']['AutoUpdate']['hidden']) + # Only show manual update options if automatic update disabled + if self.struct['update']['settings']['AutoUpdate']['value'] == '0': + if 'hidden' in self.struct['update']['settings']['Channel']: + del(self.struct['update']['settings']['Channel']['hidden']) + if 'hidden' in self.struct['update']['settings']['Build']: + del(self.struct['update']['settings']['Build']['hidden']) + else: + self.struct['update']['settings']['Channel']['hidden'] = 'true' + self.struct['update']['settings']['Build']['hidden'] = 'true' + else: + # Hide automatic update and show manual update options + self.struct['update']['settings']['AutoUpdate']['hidden'] = 'true' if 'hidden' in self.struct['update']['settings']['Channel']: del(self.struct['update']['settings']['Channel']['hidden']) if 'hidden' in self.struct['update']['settings']['Build']: del(self.struct['update']['settings']['Build']['hidden']) - else: - self.struct['update']['settings']['Channel']['hidden'] = 'true' - self.struct['update']['settings']['Build']['hidden'] = 'true' - else: - # Hide automatic update and show manual update options - self.struct['update']['settings']['AutoUpdate']['hidden'] = 'true' - if 'hidden' in self.struct['update']['settings']['Channel']: - del(self.struct['update']['settings']['Channel']['hidden']) - if 'hidden' in self.struct['update']['settings']['Build']: - del(self.struct['update']['settings']['Build']['hidden']) - - # Refresh json and available build channels if ReleaseChannel is stable, testing or custom with a custom URL set - if release_channel != 'custom' or (release_channel == 'custom' and self.struct['update']['settings']['CustomChannel1']['value']): - self.update_json = self.build_json() - self.struct['update']['settings']['Channel']['values'] = self.get_channels() + + # Refresh json for available build channels if ReleaseChannel is stable, testing, or custom with URL set + if release_channel != 'custom' or (release_channel == 'custom' and self.struct['update']['settings']['CustomChannel1']['value']): + self.update_json = self.build_json() + self.struct['update']['settings']['Channel']['values'] = self.get_channels() @log.log_function()