Skip to content

Commit

Permalink
Merge pull request #18402 from Snuffleupagus/updatedPreference-move-l…
Browse files Browse the repository at this point in the history
…istener

Move the "updatedPreference" event listener registration
  • Loading branch information
timvandermeij authored Jul 6, 2024
2 parents fe69243 + 9e352a8 commit bb3e316
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions web/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,13 @@ class BasePreferences {
typeof prefVal === typeof val ? prefVal : val;
}
AppOptions.setAll(options, /* init = */ true);

if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
window.addEventListener("updatedPreference", evt => {
this.#updatePref(evt.detail);
});
}
}
);

if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
window.addEventListener("updatedPreference", evt => {
this.#updatePref(evt.detail);
});
this.eventBus = null;
}
}
Expand All @@ -101,10 +98,11 @@ class BasePreferences {
throw new Error("Not implemented: _readFromStorage");
}

#updatePref({ name, value }) {
async #updatePref({ name, value }) {
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
throw new Error("Not implemented: #updatePref");
}
await this.#initializedPromise;

if (name in this.#browserDefaults) {
if (typeof value !== typeof this.#browserDefaults[name]) {
Expand Down

0 comments on commit bb3e316

Please sign in to comment.