Skip to content

Commit 4b84c14

Browse files
committed
šŸ› Regenerate the alchemy.settings object when updating any setting's value
1 parent ca0621d commit 4b84c14

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

ā€ŽCHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Fix `_modelInstance` cache when keys are not strings
44
* Fix certain settings not being applied if they're created after generating the main system setting object
55
* Fix settings proxy objects
6+
* Regenerate the `alchemy.settings` object when updating any setting's value
67

78
## 1.4.0-alpha.7 (2024-10-10)
89

ā€Žlib/app/model/system_setting_model.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,16 @@ SystemSetting.setDocumentMethod(function applySetting(do_actions = true) {
147147
alchemy.system_settings.forceValueInstanceAtPath(this.setting_id, existing_value);
148148
}
149149

150+
let result;
151+
150152
if (do_actions) {
151-
return existing_value.setValue(this.configuration.value);
153+
result = existing_value.setValue(this.configuration.value);
152154
} else {
153-
return existing_value.setValueSilently(this.configuration.value);
155+
result = existing_value.setValueSilently(this.configuration.value);
154156
}
157+
158+
// And now force the settings to update!
159+
alchemy.refreshSettingsObject();
160+
161+
return result;
155162
});

ā€Žlib/core/alchemy.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,21 @@ Alchemy.setMethod(function setSetting(path, value) {
580580
this.system_settings.setPathSilently(path, value);
581581

582582
if (this.started) {
583-
this.settings = this.system_settings.toObject();
583+
this.refreshSettingsObject();
584584
}
585585
});
586586

587+
/**
588+
* Refresh the settings object
589+
*
590+
* @author Jelle De Loecker <jelle@elevenways.be>
591+
* @since 1.4.0
592+
* @version 1.4.0
593+
*/
594+
Alchemy.setMethod(function refreshSettingsObject() {
595+
this.settings = this.system_settings.toObject();
596+
});
597+
587598
/**
588599
* Get a setting value
589600
*

0 commit comments

Comments
Ā (0)