Merge pull request #15 from CSCD01/issue-1607-bugfix

fixed window close issue
This commit is contained in:
JoeyHuang 2020-04-07 11:19:04 -04:00 committed by GitHub
commit 2547f79a07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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,13 @@ 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;
// Since creating new window will open a default tab,
// take the tab id here, and we could delete it after moving
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
}); });