Merge pull request #777 from jonathanKingston/container-removal-fixes
Handle removing containers to refresh menus and remove assignments. F…
This commit is contained in:
commit
2831d019f5
2 changed files with 13 additions and 7 deletions
|
@ -25,13 +25,12 @@ const backgroundLogic = {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
async deleteContainer(userContextId) {
|
async deleteContainer(userContextId, removed = false) {
|
||||||
await this._closeTabs(userContextId);
|
await this._closeTabs(userContextId);
|
||||||
await browser.contextualIdentities.remove(this.cookieStoreId(userContextId));
|
if (!removed) {
|
||||||
|
await browser.contextualIdentities.remove(this.cookieStoreId(userContextId));
|
||||||
|
}
|
||||||
assignManager.deleteContainer(userContextId);
|
assignManager.deleteContainer(userContextId);
|
||||||
await browser.runtime.sendMessage({
|
|
||||||
method: "forgetIdentityAndRefresh"
|
|
||||||
});
|
|
||||||
return {done: true, userContextId};
|
return {done: true, userContextId};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -157,13 +156,13 @@ const backgroundLogic = {
|
||||||
const cookieStoreId = this.cookieStoreId(userContextId);
|
const cookieStoreId = this.cookieStoreId(userContextId);
|
||||||
let tabs;
|
let tabs;
|
||||||
/* if we have no windowId we are going to close all this container (used for deleting) */
|
/* if we have no windowId we are going to close all this container (used for deleting) */
|
||||||
if (windowId) {
|
if (windowId !== false) {
|
||||||
tabs = await browser.tabs.query({
|
tabs = await browser.tabs.query({
|
||||||
cookieStoreId,
|
cookieStoreId,
|
||||||
windowId
|
windowId
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await browser.tabs.query({
|
tabs = await browser.tabs.query({
|
||||||
cookieStoreId
|
cookieStoreId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,13 @@ const messageHandler = {
|
||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (browser.contextualIdentities.onRemoved) {
|
||||||
|
browser.contextualIdentities.onRemoved.addListener(({contextualIdentity}) => {
|
||||||
|
const userContextId = backgroundLogic.getUserContextIdFromCookieStoreId(contextualIdentity.cookieStoreId);
|
||||||
|
backgroundLogic.deleteContainer(userContextId, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Handles messages from sdk code
|
// Handles messages from sdk code
|
||||||
const port = browser.runtime.connect();
|
const port = browser.runtime.connect();
|
||||||
port.onMessage.addListener(m => {
|
port.onMessage.addListener(m => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue