fixed window close issue

This commit is contained in:
joey 2020-04-06 14:32:08 -04:00
parent 8ffc33c636
commit fbff608aae

View file

@ -238,7 +238,7 @@ const backgroundLogic = {
}, },
async sortTabsByWindow() { async sortTabsByWindow() {
let windows = await browser.windows.getAll(); const windows = await browser.windows.getAll();
let containers = new Set(); let containers = new Set();
// loop through each tab to find all active containers // loop through each tab to find all active containers
@ -257,13 +257,6 @@ const backgroundLogic = {
await this._sortTabsByWindowInternal(windowId, containers[i]); await this._sortTabsByWindowInternal(windowId, containers[i]);
} }
// Logically, there shouldn't be any redundant windows
// but, maybe other addons/features conflicts, so double check to
// delete redundant windows here.
windows = await browser.windows.getAll();
for (let i = containers.length; i < windows.length; i++) {
await browser.windows.remove(windows[i].id);
}
}, },
async _sortTabsByWindowInternal(windowId, cookieStoreId) { async _sortTabsByWindowInternal(windowId, cookieStoreId) {
@ -276,11 +269,12 @@ const backgroundLogic = {
if (windowId === -1) { if (windowId === -1) {
const newWindowObj = await browser.windows.create(); const newWindowObj = await browser.windows.create();
windowId = newWindowObj.id; windowId = newWindowObj.id;
// take the tab is from the newly created window for deleting uses
newlyOpenedTabId = newWindowObj.tabs[0].id; newlyOpenedTabId = newWindowObj.tabs[0].id;
} }
// move all tabs // move all tabs
browser.tabs.move(tabs.map((tab) => tab.id), { await browser.tabs.move(tabs.map((tab) => tab.id), {
windowId: windowId, windowId: windowId,
index: -1 index: -1
}); });