This commit is contained in:
Nathan Bierema 2024-08-12 21:49:11 -04:00
parent 9580a467de
commit 458d8750b4
2 changed files with 6 additions and 8 deletions

View File

@ -249,7 +249,6 @@ const chunks: {
>;
} = {};
let monitors = 0;
let isMonitored = false;
const getId = (sender: chrome.runtime.MessageSender, name?: string) =>
sender.tab ? sender.tab.id! : name || sender.id!;
@ -418,7 +417,6 @@ function toAllTabs(msg: TabMessage) {
}
function monitorInstances(shouldMonitor: boolean, id?: string) {
if (!id && isMonitored === shouldMonitor) return;
const action = {
type: shouldMonitor ? ('START' as const) : ('STOP' as const),
};
@ -427,7 +425,6 @@ function monitorInstances(shouldMonitor: boolean, id?: string) {
} else {
toAllTabs(action);
}
isMonitored = shouldMonitor;
}
function getReducerError() {
@ -594,7 +591,7 @@ function onConnect<S, A extends Action<string>>(port: chrome.runtime.Port) {
chrome.action.enable(id);
chrome.action.setIcon({ tabId: id, path: 'img/logo/38x38.png' });
}
if (isMonitored) port.postMessage({ type: 'START' });
port.postMessage({ type: 'START' });
const state = store.getState();
if (state.instances.persisted) {
@ -623,6 +620,11 @@ function onConnect<S, A extends Action<string>>(port: chrome.runtime.Port) {
id = getId(port.sender!, port.name);
connections.monitor[id] = port;
monitorInstances(true);
listener = (msg: BackgroundAction | 'heartbeat') => {
if (msg === 'heartbeat') return;
store.dispatch(msg);
};
port.onMessage.addListener(listener);
monitors++;
port.onDisconnect.addListener(disconnect('monitor', id));
} else {

View File

@ -5,10 +5,6 @@ html
meta(charset='UTF-8')
title Redux DevTools
include ../style.pug
style.
body {
min-height: 100px;
}
body
#root