Skip to content

Commit

Permalink
Simplify new tab creation in the popup fixing issues. Fixes #781
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanKingston committed Sep 1, 2017
1 parent 65be776 commit df7d7f9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
4 changes: 0 additions & 4 deletions webextension/js/background/backgroundLogic.js
Expand Up @@ -50,10 +50,6 @@ const backgroundLogic = {
});
},

async openTab(options) {
return this.openNewTab(options);
},

async openNewTab(options) {
let url = options.url || undefined;
const userContextId = ("userContextId" in options) ? options.userContextId : 0;
Expand Down
16 changes: 0 additions & 16 deletions webextension/js/background/messageHandler.js
Expand Up @@ -17,10 +17,6 @@ const messageHandler = {
case "createOrUpdateContainer":
response = backgroundLogic.createOrUpdateContainer(m.message);
break;
case "openTab":
// Same as open-tab for index.js
response = backgroundLogic.openTab(m.message);
break;
case "neverAsk":
assignManager._neverAsk(m);
break;
Expand Down Expand Up @@ -83,18 +79,6 @@ const messageHandler = {
});
}

// Handles messages from sdk code
const port = browser.runtime.connect();
port.onMessage.addListener(m => {
switch (m.type) {
case "open-tab":
backgroundLogic.openTab(m.message);
break;
default:
throw new Error(`Unhandled message type: ${m.message}`);
}
});

browser.tabs.onActivated.addListener((info) => {
assignManager.removeContextMenu();
browser.tabs.get(info.tabId).then((tab) => {
Expand Down
8 changes: 2 additions & 6 deletions webextension/js/popup.js
Expand Up @@ -602,12 +602,8 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
|| e.target.parentNode.matches(".open-newtab")
|| e.type === "keydown") {
try {
await browser.runtime.sendMessage({
method: "openTab",
message: {
userContextId: Logic.userContextId(identity.cookieStoreId),
source: "pop-up"
}
browser.tabs.create({
cookieStoreId: identity.cookieStoreId
});
window.close();
} catch (e) {
Expand Down

0 comments on commit df7d7f9

Please sign in to comment.