Skip to content

Commit

Permalink
Merge pull request #18495 from Snuffleupagus/AppOptions-setAll-EVENT_…
Browse files Browse the repository at this point in the history
…DISPATCH

Consistently dispatch events, if needed, when setting AppOptions
  • Loading branch information
Snuffleupagus authored Jul 27, 2024
2 parents 2efa3e4 + 58c7b5b commit 3a21f03
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions web/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,18 +571,7 @@ class AppOptions {
}

static set(name, value) {
const defaultOpt = defaultOptions[name];

if (
!defaultOpt ||
!(
typeof value === typeof defaultOpt.value ||
Type[(typeof value).toUpperCase()] & defaultOpt.type
)
) {
return;
}
userOptions.set(name, value);
this.setAll({ [name]: value });
}

static setAll(options, prefs = false) {
Expand All @@ -601,15 +590,16 @@ class AppOptions {
) {
continue;
}
if (prefs) {
const { kind } = defaultOpt;
const { kind } = defaultOpt;

if (!(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)) {
continue;
}
if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) {
(events ||= new Map()).set(name, userOpt);
}
if (
prefs &&
!(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)
) {
continue;
}
if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) {
(events ||= new Map()).set(name, userOpt);
}
userOptions.set(name, userOpt);
}
Expand Down

0 comments on commit 3a21f03

Please sign in to comment.