Skip to content

Commit

Permalink
Fixed a problem that caused multiple containers to be created.
Browse files Browse the repository at this point in the history
  • Loading branch information
typeling1578 committed Mar 23, 2023
1 parent 62369e2 commit 9a48cb5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ async function updateContainerState() {
try {
await browser.contextualIdentities.remove(prefs.contextId);
} catch (e) { console.error(e) }
if (privatedContainerId) {
try {
await browser.contextualIdentities.remove(privatedContainerId);
} catch (e) { console.error(e) }
}
}
try {
await browser.contextualIdentities.get(prefs.contextId);
Expand Down Expand Up @@ -127,10 +132,11 @@ async function deleteHistory(details) {
browser.tabs.onCreated.addListener(async (tab) => {
if (privatedContainerId === tab.cookieStoreId) {
privatedTabs.push(tab);
await updateContainerState();
}
await updateContainerState();
});
browser.tabs.onRemoved.addListener(async (tabId) => {
if (privatedTabs.filter(privatedTab => privatedTab.id === tabId).length === 0) return;
privatedTabs = privatedTabs.filter(privatedTab => privatedTab.id !== tabId);
if (privatedTabs.length === 0 && started) {
await updateContainerState();
Expand Down

0 comments on commit 9a48cb5

Please sign in to comment.