From 9f4f94b378723bcac0fc846d8e6dba0541a4bf1c Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Sat, 31 Aug 2024 16:59:22 -0400 Subject: [PATCH] Simplify --- extension/src/background/store/apiMiddleware.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/extension/src/background/store/apiMiddleware.ts b/extension/src/background/store/apiMiddleware.ts index 0dd25ed5..c690861d 100644 --- a/extension/src/background/store/apiMiddleware.ts +++ b/extension/src/background/store/apiMiddleware.ts @@ -394,13 +394,6 @@ function toAllTabs(msg: TabMessage) { } } -function monitorInstances(shouldMonitor: boolean) { - const action = { - type: shouldMonitor ? ('START' as const) : ('STOP' as const), - }; - toAllTabs(action); -} - function getReducerError() { const instancesState = store.getState().instances; const payload = instancesState.states[instancesState.current]; @@ -535,7 +528,7 @@ function disconnect( } } else { monitors--; - if (monitors == 0) monitorInstances(false); + if (monitors == 0) toAllTabs({ type: 'STOP' }); } }; } @@ -587,7 +580,7 @@ function onConnect>(port: chrome.runtime.Port) { id = getId(port.sender!, port.name); connections.panel[id] = port; monitors++; - monitorInstances(true); + toAllTabs({ type: 'START' }); listener = (msg: BackgroundAction | 'heartbeat') => { if (msg === 'heartbeat') return; store.dispatch(msg);