This commit is contained in:
Nathan Bierema 2024-08-31 16:59:22 -04:00
parent ee43acccf5
commit 9f4f94b378

View File

@ -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() { function getReducerError() {
const instancesState = store.getState().instances; const instancesState = store.getState().instances;
const payload = instancesState.states[instancesState.current]; const payload = instancesState.states[instancesState.current];
@ -535,7 +528,7 @@ function disconnect(
} }
} else { } else {
monitors--; monitors--;
if (monitors == 0) monitorInstances(false); if (monitors == 0) toAllTabs({ type: 'STOP' });
} }
}; };
} }
@ -587,7 +580,7 @@ function onConnect<S, A extends Action<string>>(port: chrome.runtime.Port) {
id = getId(port.sender!, port.name); id = getId(port.sender!, port.name);
connections.panel[id] = port; connections.panel[id] = port;
monitors++; monitors++;
monitorInstances(true); toAllTabs({ type: 'START' });
listener = (msg: BackgroundAction | 'heartbeat') => { listener = (msg: BackgroundAction | 'heartbeat') => {
if (msg === 'heartbeat') return; if (msg === 'heartbeat') return;
store.dispatch(msg); store.dispatch(msg);