Simplify new tab creation in the popup fixing issues. Fixes #781
This commit is contained in:
parent
65be77665a
commit
df7d7f9c38
3 changed files with 2 additions and 26 deletions
|
@ -50,10 +50,6 @@ const backgroundLogic = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async openTab(options) {
|
|
||||||
return this.openNewTab(options);
|
|
||||||
},
|
|
||||||
|
|
||||||
async openNewTab(options) {
|
async openNewTab(options) {
|
||||||
let url = options.url || undefined;
|
let url = options.url || undefined;
|
||||||
const userContextId = ("userContextId" in options) ? options.userContextId : 0;
|
const userContextId = ("userContextId" in options) ? options.userContextId : 0;
|
||||||
|
|
|
@ -17,10 +17,6 @@ const messageHandler = {
|
||||||
case "createOrUpdateContainer":
|
case "createOrUpdateContainer":
|
||||||
response = backgroundLogic.createOrUpdateContainer(m.message);
|
response = backgroundLogic.createOrUpdateContainer(m.message);
|
||||||
break;
|
break;
|
||||||
case "openTab":
|
|
||||||
// Same as open-tab for index.js
|
|
||||||
response = backgroundLogic.openTab(m.message);
|
|
||||||
break;
|
|
||||||
case "neverAsk":
|
case "neverAsk":
|
||||||
assignManager._neverAsk(m);
|
assignManager._neverAsk(m);
|
||||||
break;
|
break;
|
||||||
|
@ -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) => {
|
browser.tabs.onActivated.addListener((info) => {
|
||||||
assignManager.removeContextMenu();
|
assignManager.removeContextMenu();
|
||||||
browser.tabs.get(info.tabId).then((tab) => {
|
browser.tabs.get(info.tabId).then((tab) => {
|
||||||
|
|
|
@ -602,12 +602,8 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
|
||||||
|| e.target.parentNode.matches(".open-newtab")
|
|| e.target.parentNode.matches(".open-newtab")
|
||||||
|| e.type === "keydown") {
|
|| e.type === "keydown") {
|
||||||
try {
|
try {
|
||||||
await browser.runtime.sendMessage({
|
browser.tabs.create({
|
||||||
method: "openTab",
|
cookieStoreId: identity.cookieStoreId
|
||||||
message: {
|
|
||||||
userContextId: Logic.userContextId(identity.cookieStoreId),
|
|
||||||
source: "pop-up"
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
window.close();
|
window.close();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue