refactored runSync and following functions

This commit is contained in:
Kendall Werts
2020-01-02 17:42:09 -06:00
parent 19dce3ba45
commit 0252f9d1c3
3 changed files with 183 additions and 114 deletions
+12 -8
View File
@@ -1,4 +1,3 @@
/* jshint esversion: 8*/
const identityState = {
storageArea: {
area: browser.storage.local,
@@ -14,10 +13,15 @@ const identityState = {
if (storageResponse && storeKey in storageResponse) {
return storageResponse[storeKey];
}
const defaultContainerState = identityState._createIdentityState();
await this.set(cookieStoreId, defaultContainerState);
return defaultContainerState;
const identities = await browser.contextualIdentities.query({});
const match = identities.find(
(identity) => identity.cookieStoreId === cookieStoreId);
if (match) {
const defaultContainerState = identityState._createIdentityState();
await this.set(cookieStoreId, defaultContainerState);
return defaultContainerState;
}
throw new Error (`${cookieStoreId} not found`);
},
set(cookieStoreId, data) {
@@ -97,11 +101,11 @@ const identityState = {
},
async lookupMACaddonUUID(cookieStoreId) {
console.log(cookieStoreId)
console.log(cookieStoreId);
const macConfigs = await this.storageArea.area.get();
for(const configKey of Object.keys(macConfigs)) {
if (configKey == "identitiesState@@_" + cookieStoreId) {
return macConfigs[configKey].macAddonUUID;
if (configKey === "identitiesState@@_" + cookieStoreId) {
return macConfigs[configKey].macAddonUUID;
}
}
return false;