Fix a moving hidden tabs to a new window. Fixes #797
This commit is contained in:
parent
ae79f0a303
commit
75deab139b
1 changed files with 28 additions and 11 deletions
|
@ -128,20 +128,37 @@ const backgroundLogic = {
|
||||||
containerState.hiddenTabs.length === 0) {
|
containerState.hiddenTabs.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const newWindowObj = await browser.windows.create({
|
let newWindowObj;
|
||||||
|
let hiddenDefaultTabToClose;
|
||||||
|
if (list.length) {
|
||||||
|
newWindowObj = await browser.windows.create({
|
||||||
tabId: list.shift().id
|
tabId: list.shift().id
|
||||||
});
|
});
|
||||||
browser.tabs.move(list.map((tab) => tab.id), {
|
browser.tabs.move(list.map((tab) => tab.id), {
|
||||||
windowId: newWindowObj.id,
|
windowId: newWindowObj.id,
|
||||||
index: -1
|
index: -1
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
//As we get a blank tab here we will need to await the tabs creation
|
||||||
|
newWindowObj = await browser.windows.create({
|
||||||
|
});
|
||||||
|
hiddenDefaultTabToClose = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
for (let object of containerState.hiddenTabs) { // eslint-disable-line prefer-const
|
||||||
browser.tabs.create(object.url || DEFAULT_TAB, {
|
showHiddenPromises.push(browser.tabs.create({
|
||||||
|
url: object.url || DEFAULT_TAB,
|
||||||
windowId: newWindowObj.id,
|
windowId: newWindowObj.id,
|
||||||
cookieStoreId
|
cookieStoreId
|
||||||
});
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hiddenDefaultTabToClose) {
|
||||||
|
// Lets wait for hidden tabs to show before closing the others
|
||||||
|
await showHiddenPromises;
|
||||||
}
|
}
|
||||||
|
|
||||||
containerState.hiddenTabs = [];
|
containerState.hiddenTabs = [];
|
||||||
|
@ -149,9 +166,9 @@ const backgroundLogic = {
|
||||||
// Let's close all the normal tab in the new window. In theory it
|
// Let's close all the normal tab in the new window. In theory it
|
||||||
// should be only the first tab, but maybe there are addons doing
|
// should be only the first tab, but maybe there are addons doing
|
||||||
// crazy stuff.
|
// crazy stuff.
|
||||||
const tabs = browser.tabs.query({windowId: newWindowObj.id});
|
const tabs = await browser.tabs.query({windowId: newWindowObj.id});
|
||||||
for (let tab of tabs) { // eslint-disable-line prefer-const
|
for (let tab of tabs) { // eslint-disable-line prefer-const
|
||||||
if (tabs.cookieStoreId !== cookieStoreId) {
|
if (tab.cookieStoreId !== cookieStoreId) {
|
||||||
browser.tabs.remove(tab.id);
|
browser.tabs.remove(tab.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue