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:
luke crouch 2017-09-07 14:28:47 -05:00 committed by GitHub
commit 6bc056e019
3 changed files with 44 additions and 14 deletions

View file

@ -63,8 +63,7 @@ const backgroundLogic = {
url = undefined;
}
// We can't open these we just have to throw them away
if (new URL(url).protocol === "about:") {
if (!this.isPermissibleURL(url)) {
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) {
requiredArguments.forEach((argument) => {
if (!(argument in options)) {
@ -118,20 +128,37 @@ const backgroundLogic = {
containerState.hiddenTabs.length === 0) {
return;
}
const newWindowObj = await browser.windows.create({
let newWindowObj;
let hiddenDefaultTabToClose;
if (list.length) {
newWindowObj = await browser.windows.create({
tabId: list.shift().id
});
browser.tabs.move(list.map((tab) => tab.id), {
windowId: newWindowObj.id,
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.
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,
cookieStoreId
});
}));
}
if (hiddenDefaultTabToClose) {
// Lets wait for hidden tabs to show before closing the others
await showHiddenPromises;
}
containerState.hiddenTabs = [];
@ -139,9 +166,9 @@ const backgroundLogic = {
// 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
// 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
if (tabs.cookieStoreId !== cookieStoreId) {
if (tab.cookieStoreId !== cookieStoreId) {
browser.tabs.remove(tab.id);
}
}

View file

@ -41,6 +41,9 @@ const identityState = {
const tabsByContainer = await browser.tabs.query({cookieStoreId, windowId});
tabsByContainer.forEach((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
// non-active.
tabObject.active = false;

View file

@ -39,7 +39,7 @@ const messageHandler = {
backgroundLogic.sortTabs();
break;
case "showTabs":
backgroundLogic.showTabs({cookieStoreId: m.cookieStoreId});
this.unhideContainer(m.cookieStoreId);
break;
case "hideTabs":
backgroundLogic.hideTabs({