Skip to content

Commit b6a98fb

Browse files
Handle removing containers to refresh menus and remove assignments. Fixes: #761, Fixes: #752
1 parent 3cc4034 commit b6a98fb

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

webextension/js/background/backgroundLogic.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ const backgroundLogic = {
2525
return false;
2626
},
2727

28-
async deleteContainer(userContextId) {
28+
async deleteContainer(userContextId, removed = false) {
2929
await this._closeTabs(userContextId);
30-
await browser.contextualIdentities.remove(this.cookieStoreId(userContextId));
30+
if (!removed) {
31+
await browser.contextualIdentities.remove(this.cookieStoreId(userContextId));
32+
}
3133
assignManager.deleteContainer(userContextId);
32-
await browser.runtime.sendMessage({
33-
method: "forgetIdentityAndRefresh"
34-
});
3534
return {done: true, userContextId};
3635
},
3736

@@ -158,13 +157,13 @@ const backgroundLogic = {
158157
const cookieStoreId = this.cookieStoreId(userContextId);
159158
let tabs;
160159
/* if we have no windowId we are going to close all this container (used for deleting) */
161-
if (windowId) {
160+
if (windowId !== false) {
162161
tabs = await browser.tabs.query({
163162
cookieStoreId,
164163
windowId
165164
});
166165
} else {
167-
await browser.tabs.query({
166+
tabs = await browser.tabs.query({
168167
cookieStoreId
169168
});
170169
}

webextension/js/background/messageHandler.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ const messageHandler = {
7575
return response;
7676
});
7777

78+
if (browser.contextualIdentities.onRemoved) {
79+
browser.contextualIdentities.onRemoved.addListener(({contextualIdentity}) => {
80+
const userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(contextualIdentity.cookieStoreId);
81+
backgroundLogic.deleteContainer(userContextId, true);
82+
});
83+
}
84+
7885
// Handles messages from sdk code
7986
const port = browser.runtime.connect();
8087
port.onMessage.addListener(m => {

0 commit comments

Comments
 (0)