From 43bef3af7c13f5296471efcd11dc0b6051a7a35c Mon Sep 17 00:00:00 2001 From: baku Date: Sat, 18 Feb 2017 21:56:36 +0100 Subject: [PATCH] Open tab should show the hidden tabs first --- index.js | 19 ++++++++++++++----- webextension/js/popup.js | 11 +++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index 357fc1c..77c68c1 100644 --- a/index.js +++ b/index.js @@ -624,7 +624,7 @@ const ContainerService = { const source = ("source" in args) ? args.source : null; // Only send telemetry for tabs opened by UI - i.e., not via showTabs - if (source) { + if (source && userContextId) { this.sendTelemetryPayload({ "event": "open-tab", "eventSource": source, @@ -633,10 +633,19 @@ const ContainerService = { }); } - const tab = browserWin.gBrowser.addTab(args.url || DEFAULT_TAB, { userContextId }); - browserWin.gBrowser.selectedTab = tab; - browserWin.focusAndSelectUrlBar(); - return true; + let promise; + if (userContextId) { + promise = this.showTabs(args); + } else { + promise = Promise.resolve(null); + } + + return promise.then(() => { + const tab = browserWin.gBrowser.addTab(args.url || DEFAULT_TAB, { userContextId }); + browserWin.gBrowser.selectedTab = tab; + browserWin.focusAndSelectUrlBar(); + return true; + }); }).catch(() => false); }, diff --git a/webextension/js/popup.js b/webextension/js/popup.js index 31219ef..5c2c8af 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -247,14 +247,9 @@ Logic.registerPanel(P_CONTAINERS_LIST, { tr.addEventListener("click", e => { if (e.target.matches(".open-newtab")) { browser.runtime.sendMessage({ - method: "showTabs", - userContextId: identity.userContextId - }).then(() => { - return browser.runtime.sendMessage({ - method: "openTab", - userContextId: identity.userContextId, - source: "pop-up" - }); + method: "openTab", + userContextId: identity.userContextId, + source: "pop-up" }).then(() => { window.close(); }).catch(() => {