diff --git a/jslib b/jslib index 53260a5be84..f67fac3eebc 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 53260a5be8456f5d45fe68dfcac59dc28ab4e8c2 +Subproject commit f67fac3eebc21b8935a54a28b7a21152c8513322 diff --git a/src/background/main.background.ts b/src/background/main.background.ts index 104a68ca0e1..8228943a441 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -280,6 +280,7 @@ export default class MainBackground { await this.setIcon(); await this.refreshBadgeAndMenu(); + await this.reseedStorage(); this.notificationsService.updateConnection(false); } @@ -339,6 +340,36 @@ export default class MainBackground { } } + async reseedStorage() { + if (!this.platformUtilsService.isChrome() && !this.platformUtilsService.isVivaldi() && + !this.platformUtilsService.isOpera()) { + return; + } + + const currentLockOption = await this.storageService.get(ConstantsService.lockOptionKey); + if (currentLockOption == null) { + return; + } + + const getStorage = (): Promise => new Promise((resolve) => { + chrome.storage.local.get(null, (o: any) => resolve(o)); + }); + + const clearStorage = (): Promise => new Promise((resolve) => { + chrome.storage.local.clear(() => resolve()); + }); + + const storage = await getStorage(); + await clearStorage(); + + for (const key in storage) { + if (!storage.hasOwnProperty(key)) { + continue; + } + await this.storageService.save(key, storage[key]); + } + } + private async buildContextMenu() { if (this.isSafari || !chrome.contextMenus || this.buildingContextMenu) { return; diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index 7aa729cf4e7..6723e48d402 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -140,7 +140,7 @@ export default class RuntimeBackground { await this.main.refreshBadgeAndMenu(); break; case 'bgReseedStorage': - await this.reseedStorage(); + await this.main.reseedStorage(); break; case 'collectPageDetailsResponse': switch (msg.sender) { @@ -390,36 +390,6 @@ export default class RuntimeBackground { }, 100); } - private async reseedStorage() { - if (!this.platformUtilsService.isChrome() && !this.platformUtilsService.isVivaldi() && - !this.platformUtilsService.isOpera()) { - return; - } - - const currentLockOption = await this.storageService.get(ConstantsService.lockOptionKey); - if (currentLockOption == null) { - return; - } - - const getStorage = (): Promise => new Promise((resolve) => { - chrome.storage.local.get(null, (o: any) => resolve(o)); - }); - - const clearStorage = (): Promise => new Promise((resolve) => { - chrome.storage.local.clear(() => resolve()); - }); - - const storage = await getStorage(); - await clearStorage(); - - for (const key in storage) { - if (!storage.hasOwnProperty(key)) { - continue; - } - await this.storageService.save(key, storage[key]); - } - } - private async setDefaultSettings() { // Default lock options to "on restart". const currentLockOption = await this.storageService.get(ConstantsService.lockOptionKey);