From fbff608aae16b7e534561f083138bf6f7ac53ee8 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 6 Apr 2020 14:32:08 -0400 Subject: [PATCH] fixed window close issue --- src/js/background/backgroundLogic.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/js/background/backgroundLogic.js b/src/js/background/backgroundLogic.js index de9f402..4589807 100644 --- a/src/js/background/backgroundLogic.js +++ b/src/js/background/backgroundLogic.js @@ -238,7 +238,7 @@ const backgroundLogic = { }, async sortTabsByWindow() { - let windows = await browser.windows.getAll(); + const windows = await browser.windows.getAll(); let containers = new Set(); // loop through each tab to find all active containers @@ -257,13 +257,6 @@ const backgroundLogic = { 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) { @@ -276,11 +269,12 @@ const backgroundLogic = { if (windowId === -1) { const newWindowObj = await browser.windows.create(); windowId = newWindowObj.id; + // take the tab is from the newly created window for deleting uses newlyOpenedTabId = newWindowObj.tabs[0].id; } // move all tabs - browser.tabs.move(tabs.map((tab) => tab.id), { + await browser.tabs.move(tabs.map((tab) => tab.id), { windowId: windowId, index: -1 });