combined getByContainer and getAllAssignedSites
This commit is contained in:
parent
9788e159ae
commit
e8f8123c4c
1 changed files with 24 additions and 19 deletions
|
@ -85,37 +85,42 @@ const assignManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async deleteContainer(userContextId) {
|
async deleteContainer(userContextId) {
|
||||||
const sitesByContainer = await this.getByContainer(userContextId);
|
const sitesByContainer = await this.getAssignedSites(userContextId);
|
||||||
this.area.remove(Object.keys(sitesByContainer));
|
this.area.remove(Object.keys(sitesByContainer));
|
||||||
},
|
},
|
||||||
|
|
||||||
async getByContainer(userContextId) {
|
async getAssignedSites(userContextId = null) {
|
||||||
const sites = {};
|
const sites = {};
|
||||||
const siteConfigs = await this.area.get();
|
const siteConfigs = await this.area.get();
|
||||||
Object.keys(siteConfigs).forEach((key) => {
|
for(const key of Object.keys(siteConfigs)) {
|
||||||
|
if (key.includes("siteContainerMap@@_")) {
|
||||||
// For some reason this is stored as string... lets check them both as that
|
// For some reason this is stored as string... lets check them both as that
|
||||||
if (String(siteConfigs[key].userContextId) === String(userContextId)) {
|
if (!!userContextId && String(siteConfigs[key].userContextId) !== String(userContextId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const site = siteConfigs[key];
|
const site = siteConfigs[key];
|
||||||
// In hindsight we should have stored this
|
// In hindsight we should have stored this
|
||||||
// TODO file a follow up to clean the storage onLoad
|
// TODO file a follow up to clean the storage onLoad
|
||||||
site.hostname = key.replace(/^siteContainerMap@@_/, "");
|
site.hostname = key.replace(/^siteContainerMap@@_/, "");
|
||||||
sites[key] = site;
|
sites[key] = site;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
return sites;
|
return sites;
|
||||||
},
|
},
|
||||||
|
|
||||||
async getAllAssignedSites() {
|
// async getAssignedSites(userContextId = null) {
|
||||||
const sites = {};
|
// const sites = {};
|
||||||
const siteConfigs = await this.area.get();
|
// const siteConfigs = await this.area.get();
|
||||||
for(const key of Object.keys(siteConfigs)) {
|
// for(const key of Object.keys(siteConfigs)) {
|
||||||
if (key.includes("siteContainerMap@@_")) {
|
// if (key.includes("siteContainerMap@@_")) {
|
||||||
const site = siteConfigs[key];
|
// if(userContextId==null) {
|
||||||
sites[key] = site;
|
// const site = siteConfigs[key];
|
||||||
}
|
// sites[key] = site;
|
||||||
}
|
// }
|
||||||
return sites;
|
// }
|
||||||
}
|
// }
|
||||||
|
// return sites;
|
||||||
|
// }
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -446,7 +451,7 @@ const assignManager = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_getByContainer(userContextId) {
|
_getByContainer(userContextId) {
|
||||||
return this.storageArea.getByContainer(userContextId);
|
return this.storageArea.getAssignedSites(userContextId);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeContextMenu() {
|
removeContextMenu() {
|
||||||
|
@ -587,7 +592,7 @@ async function backup() {
|
||||||
await browser.storage.sync.set({ identities: identities });
|
await browser.storage.sync.set({ identities: identities });
|
||||||
const cookieStoreIDmap = await identityState.getCookieStoreIDuuidMap();
|
const cookieStoreIDmap = await identityState.getCookieStoreIDuuidMap();
|
||||||
await browser.storage.sync.set({ cookieStoreIDmap: cookieStoreIDmap });
|
await browser.storage.sync.set({ cookieStoreIDmap: cookieStoreIDmap });
|
||||||
const assignedSites = await assignManager.storageArea.getAllAssignedSites();
|
const assignedSites = await assignManager.storageArea.getAssignedSites();
|
||||||
await browser.storage.sync.set({ assignedSites: assignedSites});
|
await browser.storage.sync.set({ assignedSites: assignedSites});
|
||||||
const storage = await browser.storage.sync.get();
|
const storage = await browser.storage.sync.get();
|
||||||
console.log("in sync: ", storage);
|
console.log("in sync: ", storage);
|
||||||
|
@ -670,7 +675,7 @@ async function restoreFirstRun(inSync) {
|
||||||
browser.contextualIdentities.update(match.cookieStoreId, {name: syncIdentity.name, color: syncIdentity.color, icon: syncIdentity.icon});
|
browser.contextualIdentities.update(match.cookieStoreId, {name: syncIdentity.name, color: syncIdentity.color, icon: syncIdentity.icon});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const assignedSitesBrowser = await assignManager.storageArea.getAllAssignedSites();
|
const assignedSitesBrowser = await assignManager.storageArea.getAssignedSites();
|
||||||
console.log(assignedSitesBrowser);
|
console.log(assignedSitesBrowser);
|
||||||
const syncAssignedSites = inSync.assignedSites;
|
const syncAssignedSites = inSync.assignedSites;
|
||||||
console.log(syncAssignedSites);
|
console.log(syncAssignedSites);
|
||||||
|
|
Loading…
Add table
Reference in a new issue