diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index 479c4b5..58965c8 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -712,8 +712,7 @@ async function reconcileIdentitiesByName(inSync){ const cookieStoreIDmap = inSync.cookieStoreIDmap; for (const syncIdentity of inSync.identities) { syncIdentity.macAddonUUID = cookieStoreIDmap[syncIdentity.cookieStoreId]; - const compareNames = function (localIdentity) { return (localIdentity.name === syncIdentity.name); }; - const match = localIdentities.find(compareNames); + const match = localIdentities.find(localIdentity => localIdentity.name === syncIdentity.name); if (!match) { console.log("create new ident: ", syncIdentity.name) newIdentity = await browser.contextualIdentities.create({name: syncIdentity.name, color: syncIdentity.color, icon: syncIdentity.icon}); diff --git a/src/js/background/identityState.js b/src/js/background/identityState.js index 7ccae7c..8db6cf1 100644 --- a/src/js/background/identityState.js +++ b/src/js/background/identityState.js @@ -67,12 +67,17 @@ const identityState = { return this.storageArea.set(cookieStoreId, containerState); }, + async updateUUID(cookieStoreId, uuid) { - const containerState = await this.storageArea.get(cookieStoreId); - containerState.macAddonUUID = uuid; - await this.storageArea.set(cookieStoreId, containerState); - return; + if (cookieStoreId && uuid) { + const containerState = await this.storageArea.get(cookieStoreId); + containerState.macAddonUUID = uuid; + await this.storageArea.set(cookieStoreId, containerState); + return; + } + throw new Error ("cookieStoreId or uuid missing"); }, + async addUUID(cookieStoreId) { return await this.updateUUID(cookieStoreId, uuidv4()); },