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
|
// 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,
|
LAST_CREATED_TAB_TIMER: 2000,
|
||||||
unhideQueue: [],
|
unhideQueue: [],
|
||||||
|
activeTab: -1,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
// Handles messages from webextension code
|
// Handles messages from webextension code
|
||||||
|
@ -89,6 +90,7 @@ const messageHandler = {
|
||||||
|
|
||||||
browser.tabs.onActivated.addListener((info) => {
|
browser.tabs.onActivated.addListener((info) => {
|
||||||
assignManager.removeContextMenu();
|
assignManager.removeContextMenu();
|
||||||
|
this.activeTab = info.tabId;
|
||||||
browser.tabs.get(info.tabId).then((tab) => {
|
browser.tabs.get(info.tabId).then((tab) => {
|
||||||
assignManager.calculateContextMenu(tab);
|
assignManager.calculateContextMenu(tab);
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
|
@ -106,11 +108,15 @@ const messageHandler = {
|
||||||
}
|
}
|
||||||
assignManager.removeContextMenu();
|
assignManager.removeContextMenu();
|
||||||
|
|
||||||
browser.tabs.get(details.tabId).then((tab) => {
|
// make sure to update the context menu only if the request was completed
|
||||||
assignManager.calculateContextMenu(tab);
|
// for the currently active tab
|
||||||
}).catch((e) => {
|
if (details.tabId === this.activeTab) {
|
||||||
throw e;
|
browser.tabs.get(details.tabId).then((tab) => {
|
||||||
});
|
assignManager.calculateContextMenu(tab);
|
||||||
|
}).catch((e) => {
|
||||||
|
throw e;
|
||||||
|
});
|
||||||
|
}
|
||||||
}, {urls: ["<all_urls>"], types: ["main_frame"]});
|
}, {urls: ["<all_urls>"], types: ["main_frame"]});
|
||||||
|
|
||||||
browser.tabs.onCreated.addListener((tab) => {
|
browser.tabs.onCreated.addListener((tab) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue