diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bd7318..254791d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Fix `_modelInstance` cache when keys are not strings * Fix certain settings not being applied if they're created after generating the main system setting object * Fix settings proxy objects +* Regenerate the `alchemy.settings` object when updating any setting's value ## 1.4.0-alpha.7 (2024-10-10) diff --git a/lib/app/model/system_setting_model.js b/lib/app/model/system_setting_model.js index 7b1cb1c..a413a79 100644 --- a/lib/app/model/system_setting_model.js +++ b/lib/app/model/system_setting_model.js @@ -147,9 +147,16 @@ SystemSetting.setDocumentMethod(function applySetting(do_actions = true) { alchemy.system_settings.forceValueInstanceAtPath(this.setting_id, existing_value); } + let result; + if (do_actions) { - return existing_value.setValue(this.configuration.value); + result = existing_value.setValue(this.configuration.value); } else { - return existing_value.setValueSilently(this.configuration.value); + result = existing_value.setValueSilently(this.configuration.value); } + + // And now force the settings to update! + alchemy.refreshSettingsObject(); + + return result; }); \ No newline at end of file diff --git a/lib/core/alchemy.js b/lib/core/alchemy.js index 2882706..826b250 100644 --- a/lib/core/alchemy.js +++ b/lib/core/alchemy.js @@ -580,10 +580,21 @@ Alchemy.setMethod(function setSetting(path, value) { this.system_settings.setPathSilently(path, value); if (this.started) { - this.settings = this.system_settings.toObject(); + this.refreshSettingsObject(); } }); +/** + * Refresh the settings object + * + * @author Jelle De Loecker + * @since 1.4.0 + * @version 1.4.0 + */ +Alchemy.setMethod(function refreshSettingsObject() { + this.settings = this.system_settings.toObject(); +}); + /** * Get a setting value *