made some suggested changes
This commit is contained in:
@@ -418,7 +418,7 @@ const assignManager = {
|
||||
const [bookmarkTreeNode] =
|
||||
await browser.bookmarks.get(info.bookmarkId);
|
||||
if (bookmarkTreeNode.type === "folder") {
|
||||
return await browser.bookmarks.getChildren(bookmarkTreeNode.id);
|
||||
return browser.bookmarks.getChildren(bookmarkTreeNode.id);
|
||||
}
|
||||
return [bookmarkTreeNode];
|
||||
}
|
||||
@@ -515,7 +515,7 @@ const assignManager = {
|
||||
// Ensure we have a cookieStore to assign to
|
||||
if (cookieStore
|
||||
&& this.isTabPermittedAssign(tab)) {
|
||||
return await this.storageArea.get(tab.url);
|
||||
return this.storageArea.get(tab.url);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
@@ -324,7 +324,7 @@ const backgroundLogic = {
|
||||
containerState.hiddenTabs = [];
|
||||
|
||||
await Promise.all(promises);
|
||||
return await identityState.storageArea.set(options.cookieStoreId, containerState);
|
||||
return identityState.storageArea.set(options.cookieStoreId, containerState);
|
||||
},
|
||||
|
||||
cookieStoreId(userContextId) {
|
||||
|
||||
@@ -39,7 +39,7 @@ const identityState = {
|
||||
|
||||
async remove(cookieStoreId) {
|
||||
const storeKey = this.getContainerStoreKey(cookieStoreId);
|
||||
return await this.area.remove([storeKey]);
|
||||
return this.area.remove([storeKey]);
|
||||
},
|
||||
|
||||
/*
|
||||
@@ -107,13 +107,13 @@ const identityState = {
|
||||
},
|
||||
|
||||
async updateUUID(cookieStoreId, uuid) {
|
||||
if (cookieStoreId && uuid) {
|
||||
const containerState = await this.storageArea.get(cookieStoreId);
|
||||
containerState.macAddonUUID = uuid;
|
||||
await this.storageArea.set(cookieStoreId, containerState);
|
||||
return uuid;
|
||||
}
|
||||
throw new Error ("cookieStoreId or uuid missing");
|
||||
if (!cookieStoreId || !uuid) {
|
||||
throw new Error ("cookieStoreId or uuid missing");
|
||||
}
|
||||
const containerState = await this.storageArea.get(cookieStoreId);
|
||||
containerState.macAddonUUID = uuid;
|
||||
await this.storageArea.set(cookieStoreId, containerState);
|
||||
return uuid;
|
||||
},
|
||||
|
||||
async addUUID(cookieStoreId) {
|
||||
|
||||
+11
-11
@@ -5,11 +5,11 @@ const sync = {
|
||||
area: browser.storage.sync,
|
||||
|
||||
async get(){
|
||||
return await this.area.get();
|
||||
return this.area.get();
|
||||
},
|
||||
|
||||
async set(options) {
|
||||
return await this.area.set(options);
|
||||
return this.area.set(options);
|
||||
},
|
||||
|
||||
async deleteIdentity(deletedIdentityUUID) {
|
||||
@@ -87,7 +87,7 @@ const sync = {
|
||||
.replace(/\//, "");
|
||||
},
|
||||
async removeInstance(installUUID) {
|
||||
console.log("removing", installUUID);
|
||||
if (SYNC_DEBUG) console.log("removing", installUUID);
|
||||
await this.area.remove(installUUID);
|
||||
return;
|
||||
},
|
||||
@@ -118,7 +118,7 @@ const sync = {
|
||||
await this.deleteSite(options.siteStoreKey);
|
||||
if (options && options.undeleteSiteStoreKey)
|
||||
await removeFromDeletedSitesList(options.undeleteSiteStoreKey);
|
||||
console.log("Backed up!");
|
||||
if (SYNC_DEBUG) console.log("Backed up!");
|
||||
await sync.checkForListenersMaybeAdd();
|
||||
|
||||
async function updateSyncIdentities() {
|
||||
@@ -150,7 +150,7 @@ const sync = {
|
||||
const date = new Date();
|
||||
const timestamp = date.getTime();
|
||||
const installUUID = sync.storageArea.getInstanceKey();
|
||||
console.log("adding", installUUID);
|
||||
if (SYNC_DEBUG) console.log("adding", installUUID);
|
||||
const identities = [];
|
||||
const siteAssignments = [];
|
||||
for (const identity of identitiesInput) {
|
||||
@@ -208,7 +208,7 @@ const sync = {
|
||||
|
||||
async errorHandledRunSync () {
|
||||
await sync.runSync().catch( async (error)=> {
|
||||
console.error("Error from runSync", error);
|
||||
if (SYNC_DEBUG) console.error("Error from runSync", error);
|
||||
await sync.checkForListenersMaybeAdd();
|
||||
});
|
||||
},
|
||||
@@ -257,7 +257,7 @@ const sync = {
|
||||
console.log("Initial State:", {syncInfo, localInfo, idents});
|
||||
}
|
||||
await sync.checkForListenersMaybeRemove();
|
||||
console.log("runSync");
|
||||
if (SYNC_DEBUG) console.log("runSync");
|
||||
|
||||
await identityState.storageArea.upgradeData();
|
||||
await assignManager.storageArea.upgradeData();
|
||||
@@ -308,7 +308,7 @@ const sync = {
|
||||
sync.init();
|
||||
|
||||
async function restore() {
|
||||
console.log("restore");
|
||||
if (SYNC_DEBUG) console.log("restore");
|
||||
await reconcileIdentities();
|
||||
await reconcileSiteAssignments();
|
||||
return;
|
||||
@@ -320,7 +320,7 @@ async function restore() {
|
||||
* different.
|
||||
*/
|
||||
async function reconcileIdentities(){
|
||||
console.log("reconcileIdentities");
|
||||
if (SYNC_DEBUG) console.log("reconcileIdentities");
|
||||
|
||||
// first delete any from the deleted list
|
||||
const deletedIdentityList =
|
||||
@@ -443,7 +443,7 @@ async function ifUUIDMatch(syncIdentity, localCookieStoreID) {
|
||||
|
||||
async function ifNoMatch(syncIdentity){
|
||||
// if no uuid match either, make new identity
|
||||
console.log("create new ident: ", syncIdentity.name);
|
||||
if (SYNC_DEBUG) console.log("create new ident: ", syncIdentity.name);
|
||||
const newIdentity =
|
||||
await browser.contextualIdentities.create({
|
||||
name: syncIdentity.name,
|
||||
@@ -463,7 +463,7 @@ async function ifNoMatch(syncIdentity){
|
||||
* If it does not exist, it is created.
|
||||
*/
|
||||
async function reconcileSiteAssignments() {
|
||||
console.log("reconcileSiteAssignments");
|
||||
if (SYNC_DEBUG) console.log("reconcileSiteAssignments");
|
||||
const assignedSitesLocal =
|
||||
await assignManager.storageArea.getAssignedSites();
|
||||
const assignedSitesFromSync =
|
||||
|
||||
+6
-6
@@ -187,7 +187,7 @@ const Logic = {
|
||||
};
|
||||
// Handle old style rejection with null and also Promise.reject new style
|
||||
try {
|
||||
return await browser.contextualIdentities.get(cookieStoreId) || defaultContainer;
|
||||
return browser.contextualIdentities.get(cookieStoreId) || defaultContainer;
|
||||
} catch (e) {
|
||||
return defaultContainer;
|
||||
}
|
||||
@@ -357,12 +357,12 @@ const Logic = {
|
||||
|
||||
getAssignmentObjectByContainer(userContextId) {
|
||||
if (userContextId) {
|
||||
return browser.runtime.sendMessage({
|
||||
method: "getAssignmentObjectByContainer",
|
||||
message: { userContextId }
|
||||
});
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
return browser.runtime.sendMessage({
|
||||
method: "getAssignmentObjectByContainer",
|
||||
message: { userContextId }
|
||||
});
|
||||
},
|
||||
|
||||
setOrRemoveAssignment(tabId, url, userContextId, value) {
|
||||
|
||||
Reference in New Issue
Block a user