Merge pull request #794 from jonathanKingston/hide-button-in-queue
Add show button to use showing queue to prevent dupes. Fixes #793
This commit is contained in:
commit
6bc056e019
3 changed files with 44 additions and 14 deletions
|
@ -63,8 +63,7 @@ const backgroundLogic = {
|
||||||
url = undefined;
|
url = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can't open these we just have to throw them away
|
if (!this.isPermissibleURL(url)) {
|
||||||
if (new URL(url).protocol === "about:") {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +75,17 @@ const backgroundLogic = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isPermissibleURL(url) {
|
||||||
|
const protocol = new URL(url).protocol;
|
||||||
|
// We can't open these we just have to throw them away
|
||||||
|
if (protocol === "about:"
|
||||||
|
|| protocol === "chrome:"
|
||||||
|
|| protocol === "moz-extension:") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
checkArgs(requiredArguments, options, methodName) {
|
checkArgs(requiredArguments, options, methodName) {
|
||||||
requiredArguments.forEach((argument) => {
|
requiredArguments.forEach((argument) => {
|
||||||
if (!(argument in options)) {
|
if (!(argument in options)) {
|
||||||
|
@ -118,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 = [];
|
||||||
|
@ -139,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,9 @@ const identityState = {
|
||||||
const tabsByContainer = await browser.tabs.query({cookieStoreId, windowId});
|
const tabsByContainer = await browser.tabs.query({cookieStoreId, windowId});
|
||||||
tabsByContainer.forEach((tab) => {
|
tabsByContainer.forEach((tab) => {
|
||||||
const tabObject = this._createTabObject(tab);
|
const tabObject = this._createTabObject(tab);
|
||||||
|
if (!backgroundLogic.isPermissibleURL(tab.url)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// This tab is going to be closed. Let's mark this tabObject as
|
// This tab is going to be closed. Let's mark this tabObject as
|
||||||
// non-active.
|
// non-active.
|
||||||
tabObject.active = false;
|
tabObject.active = false;
|
||||||
|
|
|
@ -39,7 +39,7 @@ const messageHandler = {
|
||||||
backgroundLogic.sortTabs();
|
backgroundLogic.sortTabs();
|
||||||
break;
|
break;
|
||||||
case "showTabs":
|
case "showTabs":
|
||||||
backgroundLogic.showTabs({cookieStoreId: m.cookieStoreId});
|
this.unhideContainer(m.cookieStoreId);
|
||||||
break;
|
break;
|
||||||
case "hideTabs":
|
case "hideTabs":
|
||||||
backgroundLogic.hideTabs({
|
backgroundLogic.hideTabs({
|
||||||
|
|
Loading…
Add table
Reference in a new issue