1
Fork 0

Fix: Replace usage of local with sync storage (fixes #9)

This commit is contained in:
Bauke 2019-11-10 19:37:31 +01:00
parent 32b72db90d
commit 91780f9044
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
2 changed files with 6 additions and 8 deletions

View File

@ -221,7 +221,7 @@ async function removeAllDataHandler(event: MouseEvent): Promise<void> {
return;
}
await browser.storage.local.clear();
await browser.storage.sync.clear();
flashMessage(
'Data removed, reloading this page to reinitialize default settings.'
);

View File

@ -43,14 +43,12 @@ export const defaultSettings: Settings = {
let debug = true;
export async function getSettings(): Promise<Settings> {
// 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<Settings> {
export async function setSettings(
newSettings: Partial<Settings>
): Promise<void> {
return browser.storage.local.set(newSettings);
return browser.storage.sync.set(newSettings);
}
export function log(message: any, override = false): void {