UI: Do not save unchanged extension settings to settings.yaml

This commit is contained in:
oobabooga 2024-01-10 03:48:30 -08:00
parent bb2c4707c4
commit b3fc2cd887
2 changed files with 13 additions and 8 deletions

View File

@ -19,9 +19,8 @@ def apply_settings(extension, name):
for param in extension.params:
_id = f"{name}-{param}"
if _id not in shared.settings:
continue
shared.default_settings[_id] = extension.params[param]
if _id in shared.settings:
extension.params[param] = shared.settings[_id]
@ -40,11 +39,15 @@ def load_extensions():
raise
extension = getattr(extensions, name).script
# Only run setup() and apply settings from settings.yaml once
if extension not in setup_called:
apply_settings(extension, name)
if extension not in setup_called and hasattr(extension, "setup"):
setup_called.add(extension)
if hasattr(extension, "setup"):
extension.setup()
setup_called.add(extension)
state[name] = [True, i]
except:
logger.error(f'Failed to load the extension "{name}".')

View File

@ -232,6 +232,8 @@ def save_settings(state, preset, extensions_list, show_controls, theme_state):
params = getattr(extension, 'params')
for param in params:
_id = f"{extension_name}-{param}"
# Only save if different from default value
if param not in shared.default_settings or params[param] != shared.default_settings[param]:
output[_id] = params[param]
# Do not save unchanged settings