Skip to content

Commit

Permalink
fixes could not establish connection error on extension start
Browse files Browse the repository at this point in the history
  • Loading branch information
Royal-lobster committed Nov 25, 2023
1 parent 12c4943 commit 3abc07e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/pages/background/sidebar/sendSidebarShortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ export const sendSidebarShortcut = () => {

// Send shortcut to client
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
if (tabs[0].id)
chrome.tabs.sendMessage(tabs[0].id, {
action: 'sidebar-shortcut',
shortcut,
if (tabs[0].id) {
chrome.tabs.onUpdated.addListener(function listener(tabId, info) {
if (info.status === 'complete' && tabId === tabs[0].id) {
chrome.tabs.sendMessage(tabs[0].id, {
action: 'sidebar-shortcut',
shortcut,
})
chrome.tabs.onUpdated.removeListener(listener)
}
})
}
})
})
}

0 comments on commit 3abc07e

Please sign in to comment.