Skip to content

Commit

Permalink
Preferences util: Remove local storage loop delay (AprilSylph#1223)
Browse files Browse the repository at this point in the history
Co-authored-by: nightpool <[email protected]>
  • Loading branch information
marcustyphoon and nightpool authored Aug 19, 2023
1 parent f6ac6f3 commit 518b9db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/util/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const getPreferences = async function (scriptName) {
const scriptManifestURL = browser.runtime.getURL(`/scripts/${scriptName}.json`);
const scriptManifestFile = await fetch(scriptManifestURL);
const scriptManifest = await scriptManifestFile.json();
const storage = await browser.storage.local.get();

const { preferences = {} } = scriptManifest;
const unsetPreferences = {};
Expand All @@ -15,11 +16,11 @@ export const getPreferences = async function (scriptName) {
if (preference.type === 'iframe') { continue; }

const storageKey = `${scriptName}.preferences.${key}`;
const { [storageKey]: savedPreference } = await browser.storage.local.get(storageKey);
const savedPreference = storage[storageKey];

if (savedPreference === undefined) {
if (preference.inherit) {
const { [preference.inherit]: inheritedDefault } = await browser.storage.local.get(preference.inherit);
const inheritedDefault = storage[preference.inherit];
if (inheritedDefault !== undefined) {
preference.default = inheritedDefault;
browser.storage.local.remove(preference.inherit);
Expand Down

0 comments on commit 518b9db

Please sign in to comment.