fixed initial container sync entry dupe

This commit is contained in:
Kendall Werts 2020-01-29 18:30:30 -06:00
parent d7b1e7274f
commit 88d8edce7e
3 changed files with 30 additions and 12 deletions

View file

@ -2,7 +2,7 @@
"name": "testpilot-containers", "name": "testpilot-containers",
"title": "Multi-Account 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.", "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", "author": "Andrea Marchesini, Luke Crouch and Jonathan Kingston",
"bugs": { "bugs": {
"url": "https://github.com/mozilla/multi-account-containers/issues" "url": "https://github.com/mozilla/multi-account-containers/issues"

View file

@ -16,10 +16,15 @@ const sync = {
const deletedIdentityList = const deletedIdentityList =
await sync.storageArea.getDeletedIdentityList(); await sync.storageArea.getDeletedIdentityList();
if ( if (
deletedIdentityList.find(element => element === deletedIdentityUUID) ! deletedIdentityList.find(element => element === deletedIdentityUUID)
) return; ) {
deletedIdentityList.push(deletedIdentityUUID); deletedIdentityList.push(deletedIdentityUUID);
await sync.storageArea.set({ deletedIdentityList }); await sync.storageArea.set({ deletedIdentityList });
}
await this.removeIdentityKeyFromSync(deletedIdentityUUID);
},
async removeIdentityKeyFromSync(deletedIdentityUUID) {
await sync.storageArea.area.remove( "identity@@_" + deletedIdentityUUID); await sync.storageArea.area.remove( "identity@@_" + deletedIdentityUUID);
}, },
@ -337,8 +342,20 @@ async function reconcileIdentities(){
} }
} }
} }
const localIdentities = await browser.contextualIdentities.query({}); 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 = const syncIdentities =
await sync.storageArea.getIdentities(); await sync.storageArea.getIdentities();
// now compare all containers for matching names. // 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 // Sync is truth. If all is the same, update the local uuid to match sync
await identityState.updateUUID( if (localMatch.macAddonUUID !== syncIdentity.macAddonUUID) {
localMatch.cookieStoreId, await identityState.updateUUID(
syncIdentity.macAddonUUID localMatch.cookieStoreId,
); syncIdentity.macAddonUUID
);
}
// TODOkmw: update any site assignment UUIDs // TODOkmw: update any site assignment UUIDs
} }

View file

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Firefox Multi-Account Containers", "name": "Firefox Multi-Account Containers",
"version": "6.1.4", "version": "6.1.5",
"incognito": "not_allowed", "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.", "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": { "icons": {