community: the inbox check belongs to the app, not to the page that happened to be open

This commit is contained in:
KeelrLeek committed 2026-09-03 12:38:57 -05:00
1 parent fd216ecd3d
commit b3c121fa94
3 files changed
+77 -18

No files matched your search

+9 -6
View File
@@ -134,6 +134,11 @@
const hue = $derived(key ? hueOf(key) : null);
const freenetOn = $derived(!!community.freenet?.enabled);
const nodeUp = $derived(adapterConnected(community.freenet?.status));
// A boolean, deliberately: reading community.inbox?.published straight from
// an effect makes that effect depend on the whole record, and a check
// REPLACES the record — which re-ran the effect, which checked again. A
// derived only notifies when its value actually flips.
const inboxLive = $derived(!!community.inbox?.published);
const online = $derived(app.connection === "online");
const me = $derived(app.username ?? "");
const ownLink = $derived(community.links?.own ?? null);
@@ -449,14 +454,12 @@
const id = await shareImport(card);
if (id) goToView("playlist", { playlistId: id, label: card.name });
}
// The inbox is polled while this page is open and the node is up: on
// arrival and every 90 s. Sealed cargo becomes friend requests and share
// cards through the same stores the PM carry feeds.
// The app polls the inbox for the whole session (startInboxWatch, in
// community.svelte.js) — arriving here only asks for a fresh read now, so
// the page opens on current state instead of waiting out the interval.
$effect(() => {
if (!nodeUp || !key || !community.inbox?.published) return;
if (!nodeUp || !key || !inboxLive) return;
untrack(() => void checkInbox());
const t = setInterval(() => void checkInbox(), 90_000);
return () => clearInterval(t);
});
let addKey = $state("");
// ---- spaces ------------------------------------------------------------