From d7c0a3d9e187d7a2dbac252cb4df72d8da5209b0 Mon Sep 17 00:00:00 2001 From: Kendall Werts Date: Tue, 14 Jan 2020 16:05:46 -0600 Subject: [PATCH] Fixed infinite loop in updating uuid for identities. --- src/js/background/identityState.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/js/background/identityState.js b/src/js/background/identityState.js index d260ca5..e1b281f 100644 --- a/src/js/background/identityState.js +++ b/src/js/background/identityState.js @@ -12,11 +12,13 @@ const identityState = { const storageResponse = await this.area.get([storeKey]); if (storageResponse && storeKey in storageResponse) { if (!storageResponse[storeKey].macAddonUUID){ - await identityState.addUUID(cookieStoreId); - return this.get(cookieStoreId); + storageResponse[storeKey].macAddonUUID = uuidv4(); + await this.set(cookieStoreId, storageResponse[cookieStoreId]); } return storageResponse[storeKey]; } + // If local storage doesn't have an entry, look it up to make sure it's + // an in-use identity. const identities = await browser.contextualIdentities.query({}); const match = identities.find( (identity) => identity.cookieStoreId === cookieStoreId); @@ -60,15 +62,14 @@ const identityState = { continue; } if (!macConfigs[configKey].macAddonUUID) { - await identityState.addUUID(cookieStoreId); + await identityState.storageArea.get(cookieStoreId); } } } for (const identity of identitiesList) { // ensure all identities have an entry in local storage - const data = await this.get(identity.cookieStoreId); - await this.set(identity.cookieStoreId, data); + await identityState.addUUID(identity.cookieStoreId); } } }, @@ -116,7 +117,7 @@ const identityState = { }, async addUUID(cookieStoreId) { - return await this.updateUUID(cookieStoreId, uuidv4()); + await this.storageArea.get(cookieStoreId); }, async lookupMACaddonUUID(cookieStoreId) {