Merge pull request #18495 from Snuffleupagus/AppOptions-setAll-EVENT_DISPATCH

Consistently dispatch events, if needed, when setting AppOptions
This commit is contained in:
Jonas Jenwald 2024-07-27 10:55:58 +02:00 committed by GitHub
commit 3a21f03b07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -571,18 +571,7 @@ class AppOptions {
} }
static set(name, value) { static set(name, value) {
const defaultOpt = defaultOptions[name]; this.setAll({ [name]: value });
if (
!defaultOpt ||
!(
typeof value === typeof defaultOpt.value ||
Type[(typeof value).toUpperCase()] & defaultOpt.type
)
) {
return;
}
userOptions.set(name, value);
} }
static setAll(options, prefs = false) { static setAll(options, prefs = false) {
@ -601,16 +590,17 @@ class AppOptions {
) { ) {
continue; continue;
} }
if (prefs) {
const { kind } = defaultOpt; const { kind } = defaultOpt;
if (!(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)) { if (
prefs &&
!(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)
) {
continue; continue;
} }
if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) { if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) {
(events ||= new Map()).set(name, userOpt); (events ||= new Map()).set(name, userOpt);
} }
}
userOptions.set(name, userOpt); userOptions.set(name, userOpt);
} }