fixed bug that was showing all assigned site in the create new container panel
This commit is contained in:
parent
6184dbb656
commit
9de6df6157
3 changed files with 36 additions and 29 deletions
|
@ -9,16 +9,6 @@ const assignManager = {
|
||||||
area: browser.storage.local,
|
area: browser.storage.local,
|
||||||
exemptedTabs: {},
|
exemptedTabs: {},
|
||||||
|
|
||||||
async getSynced() {
|
|
||||||
const beenSynced = await this.area.get("beenSynced");
|
|
||||||
if (Object.entries(beenSynced).length === 0) return false;
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
setSynced() {
|
|
||||||
this.area.set({beenSynced: true});
|
|
||||||
},
|
|
||||||
|
|
||||||
getSiteStoreKey(pageUrl) {
|
getSiteStoreKey(pageUrl) {
|
||||||
const url = new window.URL(pageUrl);
|
const url = new window.URL(pageUrl);
|
||||||
const storagePrefix = "siteContainerMap@@_";
|
const storagePrefix = "siteContainerMap@@_";
|
||||||
|
|
|
@ -12,22 +12,35 @@ const sync = {
|
||||||
return await this.area.set(options);
|
return await this.area.set(options);
|
||||||
},
|
},
|
||||||
|
|
||||||
async getStoredArray(objectKey) {
|
async getDeletedIdentityList() {
|
||||||
const storedArray = await this.getStoredItem(objectKey);
|
const storedArray = await this.getStoredItem("deletedIdentityList");
|
||||||
return (storedArray) ? storedArray : [];
|
return (storedArray) ? storedArray : [];
|
||||||
},
|
},
|
||||||
|
|
||||||
async getStoredObject(objectKey) {
|
async getIdentities() {
|
||||||
const storedObject = await this.getStoredItem(objectKey);
|
const storedArray = await this.getStoredItem("identities");
|
||||||
return (storedObject) ? storedObject : {};
|
return (storedArray) ? storedArray : [];
|
||||||
|
},
|
||||||
|
|
||||||
|
async getDeletedSiteList() {
|
||||||
|
const storedArray = await this.getStoredItem("deletedSiteList");
|
||||||
|
return (storedArray) ? storedArray : [];
|
||||||
|
},
|
||||||
|
|
||||||
|
async getCookieStoreIDMap() {
|
||||||
|
const storedArray = await this.getStoredItem("cookieStoreIDmap");
|
||||||
|
return (storedArray) ? storedArray : {};
|
||||||
|
},
|
||||||
|
|
||||||
|
async getAssignedSites() {
|
||||||
|
const storedArray = await this.getStoredItem("assignedSites");
|
||||||
|
return (storedArray) ? storedArray : {};
|
||||||
},
|
},
|
||||||
|
|
||||||
async getStoredItem(objectKey) {
|
async getStoredItem(objectKey) {
|
||||||
const outputObject = await this.get(objectKey);
|
const outputObject = await this.get(objectKey);
|
||||||
if (outputObject && outputObject[objectKey])
|
if (outputObject && outputObject[objectKey])
|
||||||
return outputObject[objectKey];
|
return outputObject[objectKey];
|
||||||
if (SYNC_DEBUG)
|
|
||||||
console.warn(objectKey, " was requested and is not available.");
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -118,9 +131,9 @@ const sync = {
|
||||||
browser.storage.onChanged.removeListener(
|
browser.storage.onChanged.removeListener(
|
||||||
sync.storageArea.onChangedListener);
|
sync.storageArea.onChangedListener);
|
||||||
const identitiesList =
|
const identitiesList =
|
||||||
await sync.storageArea.getStoredObject("identities");
|
await sync.storageArea.getIdentities();
|
||||||
const cookieStoreIDmap =
|
const cookieStoreIDmap =
|
||||||
await sync.storageArea.getStoredObject("cookieStoreIDmap");
|
await sync.storageArea.getCookieStoreIDMap();
|
||||||
for(const cookieStoreId of Object.keys(cookieStoreIDmap)) {
|
for(const cookieStoreId of Object.keys(cookieStoreIDmap)) {
|
||||||
const match = identitiesList
|
const match = identitiesList
|
||||||
.find(syncIdentity =>
|
.find(syncIdentity =>
|
||||||
|
@ -205,7 +218,7 @@ async function reconcileIdentities(){
|
||||||
|
|
||||||
// first delete any from the deleted list
|
// first delete any from the deleted list
|
||||||
const deletedIdentityList =
|
const deletedIdentityList =
|
||||||
await sync.storageArea.getStoredArray("deletedIdentityList");
|
await sync.storageArea.getDeletedIdentityList();
|
||||||
// first remove any deleted identities
|
// first remove any deleted identities
|
||||||
for (const deletedUUID of deletedIdentityList) {
|
for (const deletedUUID of deletedIdentityList) {
|
||||||
const deletedCookieStoreId =
|
const deletedCookieStoreId =
|
||||||
|
@ -217,9 +230,9 @@ async function reconcileIdentities(){
|
||||||
|
|
||||||
const localIdentities = await browser.contextualIdentities.query({});
|
const localIdentities = await browser.contextualIdentities.query({});
|
||||||
const syncIdentities =
|
const syncIdentities =
|
||||||
await sync.storageArea.getStoredArray("identities");
|
await sync.storageArea.getIdentities();
|
||||||
const cookieStoreIDmap =
|
const cookieStoreIDmap =
|
||||||
await sync.storageArea.getStoredObject("cookieStoreIDmap");
|
await sync.storageArea.getCookieStoreIDMap();
|
||||||
// now compare all containers for matching names.
|
// now compare all containers for matching names.
|
||||||
for (const syncIdentity of syncIdentities) {
|
for (const syncIdentity of syncIdentities) {
|
||||||
syncIdentity.macAddonUUID = cookieStoreIDmap[syncIdentity.cookieStoreId];
|
syncIdentity.macAddonUUID = cookieStoreIDmap[syncIdentity.cookieStoreId];
|
||||||
|
@ -323,9 +336,9 @@ async function reconcileSiteAssignments() {
|
||||||
const assignedSitesLocal =
|
const assignedSitesLocal =
|
||||||
await assignManager.storageArea.getAssignedSites();
|
await assignManager.storageArea.getAssignedSites();
|
||||||
const assignedSitesFromSync =
|
const assignedSitesFromSync =
|
||||||
await sync.storageArea.getStoredObject("assignedSites");
|
await sync.storageArea.getAssignedSites();
|
||||||
const deletedSiteList =
|
const deletedSiteList =
|
||||||
await sync.storageArea.getStoredArray("deletedSiteList");
|
await sync.storageArea.getDeletedSiteList();
|
||||||
for(const siteStoreKey of deletedSiteList) {
|
for(const siteStoreKey of deletedSiteList) {
|
||||||
if (assignedSitesLocal.hasOwnProperty(siteStoreKey)) {
|
if (assignedSitesLocal.hasOwnProperty(siteStoreKey)) {
|
||||||
assignManager
|
assignManager
|
||||||
|
@ -334,7 +347,7 @@ async function reconcileSiteAssignments() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const cookieStoreIDmap =
|
const cookieStoreIDmap =
|
||||||
await sync.storageArea.getStoredObject("cookieStoreIDmap");
|
await sync.storageArea.getCookieStoreIDMap();
|
||||||
|
|
||||||
for(const urlKey of Object.keys(assignedSitesFromSync)) {
|
for(const urlKey of Object.keys(assignedSitesFromSync)) {
|
||||||
const assignedSite = assignedSitesFromSync[urlKey];
|
const assignedSite = assignedSitesFromSync[urlKey];
|
||||||
|
|
|
@ -352,10 +352,13 @@ const Logic = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getAssignmentObjectByContainer(userContextId) {
|
getAssignmentObjectByContainer(userContextId) {
|
||||||
return browser.runtime.sendMessage({
|
if (userContextId) {
|
||||||
method: "getAssignmentObjectByContainer",
|
return browser.runtime.sendMessage({
|
||||||
message: { userContextId }
|
method: "getAssignmentObjectByContainer",
|
||||||
});
|
message: { userContextId }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return {};
|
||||||
},
|
},
|
||||||
|
|
||||||
setOrRemoveAssignment(tabId, url, userContextId, value) {
|
setOrRemoveAssignment(tabId, url, userContextId, value) {
|
||||||
|
@ -1022,6 +1025,7 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
||||||
while (tableElement.firstChild) {
|
while (tableElement.firstChild) {
|
||||||
tableElement.firstChild.remove();
|
tableElement.firstChild.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
assignmentKeys.forEach((siteKey) => {
|
assignmentKeys.forEach((siteKey) => {
|
||||||
const site = assignments[siteKey];
|
const site = assignments[siteKey];
|
||||||
const trElement = document.createElement("div");
|
const trElement = document.createElement("div");
|
||||||
|
|
Loading…
Add table
Reference in a new issue