Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,12 @@ function useSystem(hostId: string | null, minutes: number, announceWatching: boo
useRealtime("system.sample", (event) => {
// The sampler publishes for every connected host; only the machine on
// screen needs a reload.
const payload = event as { hostId?: string } | null;
if (hostId && payload?.hostId && payload.hostId !== hostId) return;
const payload = event as { hostId?: string; isPrimary?: boolean } | null;
if (hostId) {
if (payload?.hostId && payload.hostId !== hostId) return;
} else if (payload && payload.isPrimary === false) {
return;
}
void load();
});
return { cur, hist, error };
Expand Down Expand Up @@ -310,13 +314,13 @@ function useHomeVisibility() {
hasConnected.current = true;
}, [connectionState, load]);
useEffect(() => {
if (!retryPending || connectionState !== "connected") return;
if (!retryPending) return;
const timer = setTimeout(() => {
setRetryPending(false);
void load(true);
}, 5_000);
return () => clearTimeout(timer);
}, [connectionState, load, retryPending]);
}, [load, retryPending]);
useRealtime("system.home-visibility", (event) => {
const payload = event as { showOnHomepage?: boolean } | null;
if (typeof payload?.showOnHomepage === "boolean") {
Expand Down
6 changes: 5 additions & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,11 @@ export default async function plugin(bb: BbPluginApi) {
topMem: current.topMem,
uptime: current.uptime,
});
bb.realtime.publish("system.sample", { hostId, at: current.sample.ts });
bb.realtime.publish("system.sample", {
hostId,
isPrimary: hostId === primaryHostId,
at: current.sample.ts,
});
return current;
})().finally(() => sampling.delete(hostId));
sampling.set(hostId, promise);
Expand Down
Loading