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,15 +590,16 @@ class AppOptions {
) { ) {
continue; continue;
} }
if (prefs) { const { kind } = defaultOpt;
const { kind } = defaultOpt;
if (!(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)) { if (
continue; prefs &&
} !(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)
if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) { ) {
(events ||= new Map()).set(name, userOpt); continue;
} }
if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) {
(events ||= new Map()).set(name, userOpt);
} }
userOptions.set(name, userOpt); userOptions.set(name, userOpt);
} }