Skip to content

Commit

Permalink
fix 0f99d3e: mv3 prefs propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
tophf committed Dec 15, 2024
1 parent 1e34721 commit 1503e89
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/js/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {deepCopy, deepEqual, isCssDarkScheme, makePropertyPopProxy} from './util
import {onStorageChanged} from './util-webext';
import './msg-init'; // installs direct `API` handler

let busy, setReady;
let busy, ready, setReady;

/** @type {StylusClientData & {then: (cb: (data: StylusClientData) => ?) => Promise}} */
export const clientData = !__.IS_BG && (
Expand Down Expand Up @@ -252,14 +252,14 @@ function setAll(data, fromStorage) {
}

if (__.IS_BG) {
busy = new Promise(cb => (setReady = cb));
busy = ready = new Promise(cb => (setReady = cb));
busy.set = (...args) => setReady(setAll(...args));
} else if (__.MV3) {
setAll(clientData.prefs);
busy = Promise.resolve();
busy.then = fn => fn(); // run synchronously in the same microtick because the data is ready
ready = Promise.resolve();
ready.then = fn => fn(); // run synchronously in the same microtick because the data is ready
} else {
busy = clientData;
busy = ready = clientData;
}

onStorageChanged.addListener((changes, area) => {
Expand All @@ -269,7 +269,7 @@ onStorageChanged.addListener((changes, area) => {
});

export {
busy as ready,
ready,
defaultsClone as defaults,
defaults as __defaults, // direct reference, be careful!
values as __values, // direct reference, be careful!
Expand Down

0 comments on commit 1503e89

Please sign in to comment.