Skip to content

Commit

Permalink
šŸ› Regenerate the alchemy.settings object when updating any setting'ā€¦
Browse files Browse the repository at this point in the history
ā€¦s value
  • Loading branch information
skerit committed Nov 28, 2024
1 parent ca0621d commit 4b84c14
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 9 additions & 2 deletions lib/app/model/system_setting_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
13 changes: 12 additions & 1 deletion lib/core/alchemy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* @since 1.4.0
* @version 1.4.0
*/
Alchemy.setMethod(function refreshSettingsObject() {
this.settings = this.system_settings.toObject();
});

/**
* Get a setting value
*
Expand Down

0 comments on commit 4b84c14

Please sign in to comment.