From 91780f904468156445dc27ec549cd4159fdd8086 Mon Sep 17 00:00:00 2001 From: Bauke Date: Sun, 10 Nov 2019 19:37:31 +0100 Subject: [PATCH] Fix: Replace usage of local with sync storage (fixes #9) --- source/ts/options.ts | 2 +- source/ts/utilities.ts | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/source/ts/options.ts b/source/ts/options.ts index 86db139..bbf5c71 100644 --- a/source/ts/options.ts +++ b/source/ts/options.ts @@ -221,7 +221,7 @@ async function removeAllDataHandler(event: MouseEvent): Promise { return; } - await browser.storage.local.clear(); + await browser.storage.sync.clear(); flashMessage( 'Data removed, reloading this page to reinitialize default settings.' ); diff --git a/source/ts/utilities.ts b/source/ts/utilities.ts index 7b26b73..1c59531 100644 --- a/source/ts/utilities.ts +++ b/source/ts/utilities.ts @@ -43,14 +43,12 @@ export const defaultSettings: Settings = { let debug = true; export async function getSettings(): Promise { - // TODO: Replace local storage with sync storage once the extension has been - // deployed to AMO and we get a permanent ID. https://bugzil.la/1323228 - const localSettings: any = await browser.storage.local.get(defaultSettings); + const syncSettings: any = await browser.storage.sync.get(defaultSettings); const settings: Settings = { - data: {...defaultSettings.data, ...localSettings.data}, - features: {...defaultSettings.features, ...localSettings.features} + data: {...defaultSettings.data, ...syncSettings.data}, + features: {...defaultSettings.features, ...syncSettings.features} }; - debug = localSettings.features.debug; + debug = syncSettings.features.debug; // If we're in development, force debug output. if (getManifest().nodeEnv === 'development') { debug = true; @@ -62,7 +60,7 @@ export async function getSettings(): Promise { export async function setSettings( newSettings: Partial ): Promise { - return browser.storage.local.set(newSettings); + return browser.storage.sync.set(newSettings); } export function log(message: any, override = false): void {