added on/off switch and expiration date on instanceKeys in sync

on/off is in settings.
when instanceKey date is 30 days old, it is deleted

fixed bug
This commit is contained in:
Kendall Werts
2020-01-22 16:43:10 -06:00
parent d7b66eca52
commit 3aa2902cde
6 changed files with 139 additions and 78 deletions
+9 -2
View File
@@ -46,6 +46,11 @@ const assignManager = {
return this.getByUrlKey(siteStoreKey);
},
async getSyncEnabled() {
const { syncEnabled } = await browser.storage.local.get("syncEnabled");
return !!syncEnabled;
},
getByUrlKey(siteStoreKey) {
return new Promise((resolve, reject) => {
this.area.get([siteStoreKey]).then((storageResponse) => {
@@ -72,7 +77,8 @@ const assignManager = {
await this.area.set({
[siteStoreKey]: data
});
if (backup) await sync.storageArea.backup({undeleteSiteStoreKey: siteStoreKey});
const syncEnabled = await this.getSyncEnabled();
if (backup && syncEnabled) await sync.storageArea.backup({undeleteSiteStoreKey: siteStoreKey});
return;
},
@@ -81,7 +87,8 @@ const assignManager = {
// When we remove an assignment we should clear all the exemptions
this.removeExempted(pageUrlorUrlKey);
await this.area.remove([siteStoreKey]);
await sync.storageArea.backup({siteStoreKey});
const syncEnabled = await this.getSyncEnabled();
if (syncEnabled) await sync.storageArea.backup({siteStoreKey});
return;
},