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:home",
|
||||||
"about:blank"
|
"about:blank"
|
||||||
]),
|
]),
|
||||||
|
unhideQueue: [],
|
||||||
|
|
||||||
async getExtensionInfo() {
|
async getExtensionInfo() {
|
||||||
const manifestPath = browser.extension.getURL("manifest.json");
|
const manifestPath = browser.extension.getURL("manifest.json");
|
||||||
|
@ -112,6 +113,17 @@ const backgroundLogic = {
|
||||||
return list.concat(containerState.hiddenTabs);
|
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) {
|
async moveTabsToWindow(options) {
|
||||||
const requiredArguments = ["cookieStoreId", "windowId"];
|
const requiredArguments = ["cookieStoreId", "windowId"];
|
||||||
this.checkArgs(requiredArguments, options, "moveTabsToWindow");
|
this.checkArgs(requiredArguments, options, "moveTabsToWindow");
|
||||||
|
@ -123,6 +135,7 @@ const backgroundLogic = {
|
||||||
});
|
});
|
||||||
|
|
||||||
const containerState = await identityState.storageArea.get(cookieStoreId);
|
const containerState = await identityState.storageArea.get(cookieStoreId);
|
||||||
|
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
if (list.length === 0 &&
|
if (list.length === 0 &&
|
||||||
containerState.hiddenTabs.length === 0) {
|
containerState.hiddenTabs.length === 0) {
|
||||||
|
@ -152,12 +165,15 @@ const backgroundLogic = {
|
||||||
const showHiddenPromises = [];
|
const showHiddenPromises = [];
|
||||||
|
|
||||||
// Let's show the hidden tabs.
|
// Let's show the hidden tabs.
|
||||||
for (let object of containerState.hiddenTabs) { // eslint-disable-line prefer-const
|
if (!this.unhideQueue.includes(cookieStoreId)) {
|
||||||
showHiddenPromises.push(browser.tabs.create({
|
this.unhideQueue.push(cookieStoreId);
|
||||||
url: object.url || DEFAULT_TAB,
|
for (let object of containerState.hiddenTabs) { // eslint-disable-line prefer-const
|
||||||
windowId: newWindowObj.id,
|
showHiddenPromises.push(browser.tabs.create({
|
||||||
cookieStoreId
|
url: object.url || DEFAULT_TAB,
|
||||||
}));
|
windowId: newWindowObj.id,
|
||||||
|
cookieStoreId
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hiddenDefaultTabToClose) {
|
if (hiddenDefaultTabToClose) {
|
||||||
|
@ -176,7 +192,9 @@ const backgroundLogic = {
|
||||||
browser.tabs.remove(tab.id);
|
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) {
|
async _closeTabs(userContextId, windowId = false) {
|
||||||
|
@ -307,4 +325,3 @@ const backgroundLogic = {
|
||||||
return `firefox-container-${userContextId}`;
|
return `firefox-container-${userContextId}`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ const messageHandler = {
|
||||||
// We use this to catch redirected tabs that have just opened
|
// 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
|
// 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,
|
LAST_CREATED_TAB_TIMER: 2000,
|
||||||
unhideQueue: [],
|
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
// Handles messages from webextension code
|
// Handles messages from webextension code
|
||||||
|
@ -39,7 +38,7 @@ const messageHandler = {
|
||||||
backgroundLogic.sortTabs();
|
backgroundLogic.sortTabs();
|
||||||
break;
|
break;
|
||||||
case "showTabs":
|
case "showTabs":
|
||||||
this.unhideContainer(m.cookieStoreId);
|
backgroundLogic.unhideContainer(m.cookieStoreId);
|
||||||
break;
|
break;
|
||||||
case "hideTabs":
|
case "hideTabs":
|
||||||
backgroundLogic.hideTabs({
|
backgroundLogic.hideTabs({
|
||||||
|
@ -156,7 +155,7 @@ const messageHandler = {
|
||||||
this.incrementCountOfContainerTabsOpened();
|
this.incrementCountOfContainerTabsOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.unhideContainer(tab.cookieStoreId);
|
backgroundLogic.unhideContainer(tab.cookieStoreId);
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.lastCreatedTab = null;
|
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) {
|
async onFocusChangedCallback(windowId) {
|
||||||
assignManager.removeContextMenu();
|
assignManager.removeContextMenu();
|
||||||
// browserAction loses background color in new windows ...
|
// browserAction loses background color in new windows ...
|
||||||
|
|
Loading…
Add table
Reference in a new issue