review fedback
This commit is contained in:
parent
5b8cfa14ae
commit
0447e54b1c
5 changed files with 33 additions and 36 deletions
|
@ -78,7 +78,9 @@ const assignManager = {
|
|||
[siteStoreKey]: data
|
||||
});
|
||||
const syncEnabled = await this.getSyncEnabled();
|
||||
if (backup && syncEnabled) await sync.storageArea.backup({undeleteSiteStoreKey: siteStoreKey});
|
||||
if (backup && syncEnabled) {
|
||||
await sync.storageArea.backup({undeleteSiteStoreKey: siteStoreKey});
|
||||
}
|
||||
return;
|
||||
},
|
||||
|
||||
|
@ -135,7 +137,7 @@ const assignManager = {
|
|||
localIdentity => localIdentity.cookieStoreId === cookieStoreId
|
||||
);
|
||||
if (!match) {
|
||||
await this.remove(configKey.replace(/^siteContainerMap@@_/, "https://"));
|
||||
await this.remove(configKey);
|
||||
continue;
|
||||
}
|
||||
const updatedSiteAssignment = macConfigs[configKey];
|
||||
|
|
|
@ -49,6 +49,12 @@ const identityState = {
|
|||
*/
|
||||
async upgradeData() {
|
||||
const identitiesList = await browser.contextualIdentities.query({});
|
||||
|
||||
for (const identity of identitiesList) {
|
||||
// ensure all identities have an entry in local storage
|
||||
await identityState.addUUID(identity.cookieStoreId);
|
||||
}
|
||||
|
||||
const macConfigs = await this.area.get();
|
||||
for(const configKey of Object.keys(macConfigs)) {
|
||||
if (configKey.includes("identitiesState@@_")) {
|
||||
|
@ -61,16 +67,12 @@ const identityState = {
|
|||
await this.remove(cookieStoreId);
|
||||
continue;
|
||||
}
|
||||
console.log(macConfigs, configKey);
|
||||
if (!macConfigs[configKey].macAddonUUID) {
|
||||
await identityState.storageArea.get(cookieStoreId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const identity of identitiesList) {
|
||||
// ensure all identities have an entry in local storage
|
||||
await identityState.addUUID(identity.cookieStoreId);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -127,7 +129,7 @@ const identityState = {
|
|||
cookieStoreId : "firefox-container-" + cookieStoreId;
|
||||
const macConfigs = await this.storageArea.area.get();
|
||||
for(const configKey of Object.keys(macConfigs)) {
|
||||
if (configKey === this.getContainerStoreKey(cookieStoreIdKey)) {
|
||||
if (configKey === this.storageArea.getContainerStoreKey(cookieStoreIdKey)) {
|
||||
return macConfigs[configKey].macAddonUUID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,6 +118,7 @@ const sync = {
|
|||
await this.deleteSite(options.siteStoreKey);
|
||||
if (options && options.undeleteSiteStoreKey)
|
||||
await removeFromDeletedSitesList(options.undeleteSiteStoreKey);
|
||||
|
||||
if (SYNC_DEBUG) console.log("Backed up!");
|
||||
await sync.checkForListenersMaybeAdd();
|
||||
|
||||
|
@ -270,26 +271,23 @@ const sync = {
|
|||
return;
|
||||
},
|
||||
|
||||
async addContextualIdentityListeners(listenerList) {
|
||||
if(!listenerList) listenerList = syncCIListenerList;
|
||||
await browser.contextualIdentities.onCreated.addListener(listenerList[0]);
|
||||
await browser.contextualIdentities.onRemoved.addListener(listenerList[1]);
|
||||
await browser.contextualIdentities.onUpdated.addListener(listenerList[2]);
|
||||
async addContextualIdentityListeners() {
|
||||
await browser.contextualIdentities.onCreated.addListener(sync.storageArea.backup);
|
||||
await browser.contextualIdentities.onRemoved.addListener(sync.storageArea.addToDeletedList);
|
||||
await browser.contextualIdentities.onUpdated.addListener(sync.storageArea.backup);
|
||||
},
|
||||
|
||||
async removeContextualIdentityListeners(listenerList) {
|
||||
if(!listenerList) listenerList = syncCIListenerList;
|
||||
await browser.contextualIdentities.onCreated.removeListener(listenerList[0]);
|
||||
await browser.contextualIdentities.onRemoved.removeListener(listenerList[1]);
|
||||
await browser.contextualIdentities.onUpdated.removeListener(listenerList[2]);
|
||||
async removeContextualIdentityListeners() {
|
||||
await browser.contextualIdentities.onCreated.removeListener(sync.storageArea.backup);
|
||||
await browser.contextualIdentities.onRemoved.removeListener(sync.storageArea.addToDeletedList);
|
||||
await browser.contextualIdentities.onUpdated.removeListener(sync.storageArea.backup);
|
||||
},
|
||||
|
||||
async hasContextualIdentityListeners(listenerList) {
|
||||
if(!listenerList) listenerList = syncCIListenerList;
|
||||
async hasContextualIdentityListeners() {
|
||||
return (
|
||||
await browser.contextualIdentities.onCreated.hasListener(listenerList[0]) &&
|
||||
await browser.contextualIdentities.onRemoved.hasListener(listenerList[1]) &&
|
||||
await browser.contextualIdentities.onUpdated.hasListener(listenerList[2])
|
||||
await browser.contextualIdentities.onCreated.hasListener(sync.storageArea.backup) &&
|
||||
await browser.contextualIdentities.onRemoved.hasListener(sync.storageArea.addToDeletedList) &&
|
||||
await browser.contextualIdentities.onUpdated.hasListener(sync.storageArea.backup)
|
||||
);
|
||||
},
|
||||
|
||||
|
@ -360,7 +358,9 @@ async function reconcileIdentities(){
|
|||
await ifNoMatch(syncIdentity);
|
||||
continue;
|
||||
}
|
||||
await ifNamesMatch(syncIdentity, localMatch);
|
||||
|
||||
// Names match, so use the info from Sync
|
||||
await updateIdentityWithSyncInfo(syncIdentity, localMatch);
|
||||
continue;
|
||||
}
|
||||
// if no macAddonUUID, there is a problem with the sync info and it needs to be ignored.
|
||||
|
@ -376,7 +376,7 @@ async function reconcileIdentities(){
|
|||
}
|
||||
}
|
||||
|
||||
async function ifNamesMatch(syncIdentity, localMatch) {
|
||||
async function updateIdentityWithSyncInfo(syncIdentity, localMatch) {
|
||||
// Sync is truth. if there is a match, compare data and update as needed
|
||||
if (syncIdentity.color !== localMatch.color
|
||||
|| syncIdentity.icon !== localMatch.icon) {
|
||||
|
@ -474,7 +474,7 @@ async function reconcileSiteAssignments() {
|
|||
if (Object.prototype.hasOwnProperty.call(assignedSitesLocal,siteStoreKey)) {
|
||||
assignManager
|
||||
.storageArea
|
||||
.remove(siteStoreKey.replace(/^siteContainerMap@@_/, "https://"));
|
||||
.remove(siteStoreKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -548,7 +548,7 @@ async function setAssignmentWithUUID(assignedSite, urlKey) {
|
|||
assignedSite.userContextId = cookieStoreId
|
||||
.replace(/^firefox-container-/, "");
|
||||
await assignManager.storageArea.set(
|
||||
urlKey.replace(/^siteContainerMap@@_/, "https://"),
|
||||
urlKey,
|
||||
assignedSite,
|
||||
false,
|
||||
false
|
||||
|
@ -557,9 +557,3 @@ async function setAssignmentWithUUID(assignedSite, urlKey) {
|
|||
}
|
||||
throw new Error (`No cookieStoreId found for: ${uuid}, ${urlKey}`);
|
||||
}
|
||||
|
||||
const syncCIListenerList = [
|
||||
sync.storageArea.backup,
|
||||
sync.storageArea.addToDeletedList,
|
||||
sync.storageArea.backup
|
||||
];
|
||||
|
|
|
@ -25,7 +25,6 @@ async function enableDisableSync() {
|
|||
async function restoreOptions() {
|
||||
const hasPermission = await browser.permissions.contains({permissions: ["bookmarks"]});
|
||||
const { syncEnabled } = await browser.storage.local.get("syncEnabled");
|
||||
console.log(syncEnabled);
|
||||
if (hasPermission) {
|
||||
document.querySelector("#bookmarksPermissions").checked = true;
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ const Logic = {
|
|||
};
|
||||
// Handle old style rejection with null and also Promise.reject new style
|
||||
try {
|
||||
return browser.contextualIdentities.get(cookieStoreId) || defaultContainer;
|
||||
return await browser.contextualIdentities.get(cookieStoreId) || defaultContainer;
|
||||
} catch (e) {
|
||||
return defaultContainer;
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ const Logic = {
|
|||
},
|
||||
|
||||
getAssignmentObjectByContainer(userContextId) {
|
||||
if (userContextId) {
|
||||
if (!userContextId) {
|
||||
return {};
|
||||
}
|
||||
return browser.runtime.sendMessage({
|
||||
|
|
Loading…
Add table
Reference in a new issue