diff --git a/package.json b/package.json index 2375323..39d2853 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "testpilot-containers", "title": "Multi-Account Containers", "description": "Containers helps you keep all the parts of your online life contained in different tabs. Custom labels and color-coded tabs help keep different activities — like online shopping, travel planning, or checking work email — separate.", - "version": "6.1.4", + "version": "6.1.5", "author": "Andrea Marchesini, Luke Crouch and Jonathan Kingston", "bugs": { "url": "https://github.com/mozilla/multi-account-containers/issues" diff --git a/src/js/background/sync.js b/src/js/background/sync.js index 9546d7c..cc9b183 100644 --- a/src/js/background/sync.js +++ b/src/js/background/sync.js @@ -16,10 +16,15 @@ const sync = { const deletedIdentityList = await sync.storageArea.getDeletedIdentityList(); if ( - deletedIdentityList.find(element => element === deletedIdentityUUID) - ) return; - deletedIdentityList.push(deletedIdentityUUID); - await sync.storageArea.set({ deletedIdentityList }); + ! deletedIdentityList.find(element => element === deletedIdentityUUID) + ) { + deletedIdentityList.push(deletedIdentityUUID); + await sync.storageArea.set({ deletedIdentityList }); + } + await this.removeIdentityKeyFromSync(deletedIdentityUUID); + }, + + async removeIdentityKeyFromSync(deletedIdentityUUID) { await sync.storageArea.area.remove( "identity@@_" + deletedIdentityUUID); }, @@ -337,8 +342,20 @@ async function reconcileIdentities(){ } } } - const localIdentities = await browser.contextualIdentities.query({}); + const syncIdentitiesRemoveDupes = + await sync.storageArea.getIdentities(); + // find any local dupes created on sync storage and delete from sync storage + for (const localIdentity of localIdentities) { + const syncIdentitiesOfName = syncIdentitiesRemoveDupes + .filter(identity => identity.name === localIdentity.name); + if (syncIdentitiesOfName.length > 1) { + const identityMatchingContextId = syncIdentitiesOfName + .find(identity => identity.cookieStoreId === localIdentity.cookieStoreId); + if (identityMatchingContextId) + await sync.storageArea.removeIdentityKeyFromSync(identityMatchingContextId.macAddonUUID); + } + } const syncIdentities = await sync.storageArea.getIdentities(); // now compare all containers for matching names. @@ -397,11 +414,12 @@ async function updateIdentityWithSyncInfo(syncIdentity, localMatch) { } } // Sync is truth. If all is the same, update the local uuid to match sync - await identityState.updateUUID( - localMatch.cookieStoreId, - syncIdentity.macAddonUUID - ); - + if (localMatch.macAddonUUID !== syncIdentity.macAddonUUID) { + await identityState.updateUUID( + localMatch.cookieStoreId, + syncIdentity.macAddonUUID + ); + } // TODOkmw: update any site assignment UUIDs } diff --git a/src/manifest.json b/src/manifest.json index 7d36ec0..cd6d097 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Firefox Multi-Account Containers", - "version": "6.1.4", + "version": "6.1.5", "incognito": "not_allowed", "description": "Multi-Account Containers helps you keep all the parts of your online life contained in different tabs. Custom labels and color-coded tabs help keep different activities — like online shopping, travel planning, or checking work email — separate.", "icons": {