Skip to content

Commit 3e4f0f8

Browse files
committed
fix(popup): show reload message in popup on unattached tabs
1 parent c46d280 commit 3e4f0f8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

entrypoints/background.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { INVALID_URLS } from '@/utils/constants'
88
import { CONTEXT_MENU, CONTEXT_MENU_ITEM_TRANSLATE_PAGE } from '@/utils/context-menu'
99
import logger from '@/utils/logger'
1010
import { bgBroadcastRpc } from '@/utils/rpc'
11+
import { registerBackgroundRpcEvent } from '@/utils/rpc/background-fns'
1112
import { isTabValid } from '@/utils/tab'
1213
import { registerDeclarativeNetRequestRule } from '@/utils/web-request'
1314

@@ -69,9 +70,8 @@ export default defineBackground(() => {
6970
})
7071
})
7172

72-
browser.tabs.onUpdated.addListener(async (tabId, _changeInfo, tab) => {
73-
logger.info('tab updated', { tabId, changeInfo: _changeInfo, tab })
74-
unAttachedTabs.delete(tabId)
73+
browser.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
74+
logger.info('tab updated', { tabId, changeInfo, tab })
7575
if (tab.url) {
7676
await setPopupStatusBasedOnUrl(tabId, tab.url)
7777
}
@@ -112,5 +112,9 @@ export default defineBackground(() => {
112112
}
113113
})
114114

115+
registerBackgroundRpcEvent('ready', (tabId) => {
116+
unAttachedTabs.delete(tabId)
117+
})
118+
115119
logger.info('Hello background!', { id: browser.runtime.id })
116120
})

0 commit comments

Comments
 (0)