From 606198636f24329af2f5a2045a22f332cf1ec3a3 Mon Sep 17 00:00:00 2001 From: mayank Date: Thu, 13 Aug 2026 13:33:17 +0000 Subject: [PATCH] fix: scope homepage sample reloads to primary host and retry visibility load while offline --- app.tsx | 12 ++++++++---- server.ts | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app.tsx b/app.tsx index a755d38..cd2c674 100644 --- a/app.tsx +++ b/app.tsx @@ -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 }; @@ -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") { diff --git a/server.ts b/server.ts index 24ae150..87cfe70 100644 --- a/server.ts +++ b/server.ts @@ -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);