Skip to content

Commit

Permalink
blur listener deregister
Browse files Browse the repository at this point in the history
  • Loading branch information
insmac committed Dec 6, 2024
1 parent c6d0e22 commit e155064
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/web-console/src/scenes/Editor/Metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ export const Metrics = () => {
}
}, [refreshRateRef.current])

const blurListener = useCallback(() => {
tabInFocusRef.current = false
}, [])

const setupListeners = () => {
if (autoRefreshTables && refreshRate && refreshRate !== RefreshRate.OFF) {
intervalRef.current = setInterval(
Expand Down Expand Up @@ -221,12 +225,11 @@ export const Metrics = () => {

useEffect(() => {
eventBus.subscribe(EventType.TAB_FOCUS, focusListener)
eventBus.subscribe(EventType.TAB_BLUR, () => {
tabInFocusRef.current = false
})
eventBus.subscribe(EventType.TAB_BLUR, blurListener)

return () => {
eventBus.unsubscribe(EventType.TAB_FOCUS, focusListener)
eventBus.unsubscribe(EventType.TAB_BLUR, blurListener)
}
}, [])

Expand Down

0 comments on commit e155064

Please sign in to comment.