moved unhiding container to background logic
This commit is contained in:
parent
220b902144
commit
b6dd32f683
2 changed files with 27 additions and 22 deletions
|
@ -6,6 +6,7 @@ const backgroundLogic = {
|
|||
"about:home",
|
||||
"about:blank"
|
||||
]),
|
||||
unhideQueue: [],
|
||||
|
||||
async getExtensionInfo() {
|
||||
const manifestPath = browser.extension.getURL("manifest.json");
|
||||
|
@ -112,6 +113,17 @@ const backgroundLogic = {
|
|||
return list.concat(containerState.hiddenTabs);
|
||||
},
|
||||
|
||||
async unhideContainer(cookieStoreId) {
|
||||
if (!this.unhideQueue.includes(cookieStoreId)) {
|
||||
this.unhideQueue.push(cookieStoreId);
|
||||
await this.showTabs({
|
||||
cookieStoreId
|
||||
});
|
||||
this.unhideQueue.splice(this.unhideQueue.indexOf(cookieStoreId), 1);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
async moveTabsToWindow(options) {
|
||||
const requiredArguments = ["cookieStoreId", "windowId"];
|
||||
this.checkArgs(requiredArguments, options, "moveTabsToWindow");
|
||||
|
@ -123,6 +135,7 @@ const backgroundLogic = {
|
|||
});
|
||||
|
||||
const containerState = await identityState.storageArea.get(cookieStoreId);
|
||||
|
||||
// Nothing to do
|
||||
if (list.length === 0 &&
|
||||
containerState.hiddenTabs.length === 0) {
|
||||
|
@ -152,6 +165,8 @@ const backgroundLogic = {
|
|||
const showHiddenPromises = [];
|
||||
|
||||
// Let's show the hidden tabs.
|
||||
if (!this.unhideQueue.includes(cookieStoreId)) {
|
||||
this.unhideQueue.push(cookieStoreId);
|
||||
for (let object of containerState.hiddenTabs) { // eslint-disable-line prefer-const
|
||||
showHiddenPromises.push(browser.tabs.create({
|
||||
url: object.url || DEFAULT_TAB,
|
||||
|
@ -159,6 +174,7 @@ const backgroundLogic = {
|
|||
cookieStoreId
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
if (hiddenDefaultTabToClose) {
|
||||
// Lets wait for hidden tabs to show before closing the others
|
||||
|
@ -176,7 +192,9 @@ const backgroundLogic = {
|
|||
browser.tabs.remove(tab.id);
|
||||
}
|
||||
}
|
||||
return await identityState.storageArea.set(cookieStoreId, containerState);
|
||||
const rv = await identityState.storageArea.set(cookieStoreId, containerState);
|
||||
this.unhideQueue.splice(this.unhideQueue.indexOf(cookieStoreId), 1);
|
||||
return rv;
|
||||
},
|
||||
|
||||
async _closeTabs(userContextId, windowId = false) {
|
||||
|
@ -307,4 +325,3 @@ const backgroundLogic = {
|
|||
return `firefox-container-${userContextId}`;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ const messageHandler = {
|
|||
// We use this to catch redirected tabs that have just opened
|
||||
// If this were in platform we would change how the tab opens based on "new tab" link navigations such as ctrl+click
|
||||
LAST_CREATED_TAB_TIMER: 2000,
|
||||
unhideQueue: [],
|
||||
|
||||
init() {
|
||||
// Handles messages from webextension code
|
||||
|
@ -39,7 +38,7 @@ const messageHandler = {
|
|||
backgroundLogic.sortTabs();
|
||||
break;
|
||||
case "showTabs":
|
||||
this.unhideContainer(m.cookieStoreId);
|
||||
backgroundLogic.unhideContainer(m.cookieStoreId);
|
||||
break;
|
||||
case "hideTabs":
|
||||
backgroundLogic.hideTabs({
|
||||
|
@ -156,7 +155,7 @@ const messageHandler = {
|
|||
this.incrementCountOfContainerTabsOpened();
|
||||
}
|
||||
|
||||
this.unhideContainer(tab.cookieStoreId);
|
||||
backgroundLogic.unhideContainer(tab.cookieStoreId);
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.lastCreatedTab = null;
|
||||
|
@ -182,17 +181,6 @@ const messageHandler = {
|
|||
}
|
||||
},
|
||||
|
||||
async unhideContainer(cookieStoreId) {
|
||||
if (!this.unhideQueue.includes(cookieStoreId)) {
|
||||
this.unhideQueue.push(cookieStoreId);
|
||||
// Unhide all hidden tabs
|
||||
await backgroundLogic.showTabs({
|
||||
cookieStoreId
|
||||
});
|
||||
this.unhideQueue.splice(this.unhideQueue.indexOf(cookieStoreId), 1);
|
||||
}
|
||||
},
|
||||
|
||||
async onFocusChangedCallback(windowId) {
|
||||
assignManager.removeContextMenu();
|
||||
// browserAction loses background color in new windows ...
|
||||
|
|
Loading…
Add table
Reference in a new issue