Fix concurrency bug for completed request in inactive tab
This commit is contained in:
parent
351feb4495
commit
0edb67224d
1 changed files with 11 additions and 5 deletions
|
@ -4,6 +4,7 @@ const messageHandler = {
|
|||
// If this were in platform we would change how the tab opens based on "new tab" link navigations such as ctrl+click
|
||||
LAST_CREATED_TAB_TIMER: 2000,
|
||||
unhideQueue: [],
|
||||
activeTab: -1,
|
||||
|
||||
init() {
|
||||
// Handles messages from webextension code
|
||||
|
@ -89,6 +90,7 @@ const messageHandler = {
|
|||
|
||||
browser.tabs.onActivated.addListener((info) => {
|
||||
assignManager.removeContextMenu();
|
||||
this.activeTab = info.tabId;
|
||||
browser.tabs.get(info.tabId).then((tab) => {
|
||||
assignManager.calculateContextMenu(tab);
|
||||
}).catch((e) => {
|
||||
|
@ -106,11 +108,15 @@ const messageHandler = {
|
|||
}
|
||||
assignManager.removeContextMenu();
|
||||
|
||||
browser.tabs.get(details.tabId).then((tab) => {
|
||||
assignManager.calculateContextMenu(tab);
|
||||
}).catch((e) => {
|
||||
throw e;
|
||||
});
|
||||
// make sure to update the context menu only if the request was completed
|
||||
// for the currently active tab
|
||||
if (details.tabId === this.activeTab) {
|
||||
browser.tabs.get(details.tabId).then((tab) => {
|
||||
assignManager.calculateContextMenu(tab);
|
||||
}).catch((e) => {
|
||||
throw e;
|
||||
});
|
||||
}
|
||||
}, {urls: ["<all_urls>"], types: ["main_frame"]});
|
||||
|
||||
browser.tabs.onCreated.addListener((tab) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue