Container locking - simplified test code
This commit is contained in:
parent
0bf47ad806
commit
6f55671f8f
2 changed files with 15 additions and 23 deletions
|
@ -370,6 +370,16 @@ const Logic = {
|
|||
value
|
||||
});
|
||||
},
|
||||
|
||||
lockOrUnlockContainer(userContextId, isLocked) {
|
||||
return browser.runtime.sendMessage({
|
||||
method: "lockOrUnlockContainer",
|
||||
message: {
|
||||
userContextId: userContextId,
|
||||
isLocked: !!isLocked
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
generateIdentityName() {
|
||||
const defaultName = "Container #";
|
||||
|
@ -1041,16 +1051,10 @@ Logic.registerPanel(P_CONTAINER_EDIT, {
|
|||
|
||||
Logic.addEnterHandler(lockElement, async () => {
|
||||
try {
|
||||
await browser.runtime.sendMessage({
|
||||
method: "lockOrUnlockContainer",
|
||||
message: {
|
||||
userContextId: Logic.currentUserContextId(),
|
||||
isLocked: !isLocked
|
||||
}
|
||||
});
|
||||
await Logic.lockOrUnlockContainer(Logic.currentUserContextId(), !isLocked);
|
||||
this.showAssignedContainers(assignments, !isLocked);
|
||||
} catch (e) {
|
||||
throw new Error("Failed to lock/unlock. ", e.message);
|
||||
throw new Error("Failed to lock/unlock container: " + e.message);
|
||||
}
|
||||
});
|
||||
/* Container locking end */
|
||||
|
|
|
@ -53,21 +53,9 @@ module.exports = {
|
|||
|
||||
// https://github.com/mozilla/multi-account-containers/issues/847
|
||||
async setContainerIsLocked(cookieStoreId, isLocked) {
|
||||
const identityStateKey = this.getIdentityStateContainerStoreKey(cookieStoreId);
|
||||
const identityState = await background.browser.storage.local.get([identityStateKey]) || {};
|
||||
if (isLocked) {
|
||||
identityState.isLocked = "locked";
|
||||
} else {
|
||||
delete identityState.isLocked;
|
||||
}
|
||||
// Must have valid 'hiddenTabs', otherwise backgroundLogic.showTabs() throws error
|
||||
if (!identityState.hiddenTabs) { identityState.hiddenTabs = []; }
|
||||
await background.browser.storage.local.set({[identityStateKey]: identityState});
|
||||
},
|
||||
|
||||
getIdentityStateContainerStoreKey(cookieStoreId) {
|
||||
const storagePrefix = "identitiesState@@_";
|
||||
return `${storagePrefix}${cookieStoreId}`;
|
||||
const Logic = popup.dom.window.eval("Logic");
|
||||
const userContextId = Logic.userContextId(cookieStoreId);
|
||||
await Logic.lockOrUnlockContainer(userContextId, isLocked);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue