diff --git a/webextension/js/popup.js b/webextension/js/popup.js index fb0c510..1bc8af6 100644 --- a/webextension/js/popup.js +++ b/webextension/js/popup.js @@ -31,21 +31,23 @@ function hideContainerTabs(userContextId) { } function showContainerTabs(userContextId) { - const hideorshowIcon = document.querySelector(`#uci-${userContextId}-hideorshow-icon`); + return new Promise((resolve, reject) => { + const hideorshowIcon = document.querySelector(`#uci-${userContextId}-hideorshow-icon`); - browser.runtime.sendMessage({ - method: 'showTabs', - userContextId: userContextId - }).then(hiddenTabUrls=> { - hiddenTabUrls.forEach(url=> { - browser.runtime.sendMessage({ - method: 'openTab', - userContextId: userContextId, - url: url + browser.runtime.sendMessage({ + method: 'showTabs', + userContextId: userContextId + }).then(hiddenTabUrls=> { + hiddenTabUrls.forEach(url=> { + browser.runtime.sendMessage({ + method: 'openTab', + userContextId: userContextId, + url: url + }); }); - }); - }).then(() => { - hideorshowIcon.src = CONTAINER_HIDE_SRC; + }).then(() => { + hideorshowIcon.src = CONTAINER_HIDE_SRC; + }).then(resolve); }); } @@ -130,11 +132,13 @@ browser.runtime.sendMessage({method: 'queryIdentities'}).then(identities=> { } }); } else if (e.target.matches('.newtab-icon')) { - browser.runtime.sendMessage({ - method: 'openTab', - userContextId: userContextId}) - .then(() => { - window.close(); + showContainerTabs(userContextId).then(() => { + browser.runtime.sendMessage({ + method: 'openTab', + userContextId: userContextId}) + .then(() => { + window.close(); + }); }); } });