Skip to content

Commit

Permalink
fix multi tab not triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
azaky committed Oct 27, 2020
1 parent 507ec10 commit 8e5d813
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion extension/src/background/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,15 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
}
);
} else {
// handle multiple tabs
if (tabId !== sender.tab.id) {
sendResponse({
success: false,
error: 'Multiple tabs',
});
return;
}

// a session is active: return current context
sendResponse(data);
}
Expand All @@ -361,7 +370,7 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
// on a very rare case -- possibly only on development --
// when someone inits from two different tabs at the same time,
// race condition may occur
if (tabId) {
if (tabId && tabId !== sender.tab.id) {
sendResponse({
success: false,
error: 'Multiple tabs',
Expand Down

0 comments on commit 8e5d813

Please sign in to comment.