fix(ui): don't refetch the lobby on heartbeats
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Successful in 50s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 58s

The lobby refetched /user/games on every stream event, including the 10s
keep-alive heartbeat, turning it into a 10s poll. That poll's REST view of a
just-committed opponent move could flip a card (and now blink it) seconds before
the matching your_turn event — and its toast — arrived over the slower live
stream, so the new lobby-card blink appeared to lead the toast by 5-7s (variable
with stream delivery; in sync when prompt).

Gate the refetch to real events (kind !== 'heartbeat'): the card, its blink and
the toast now ride the same event (opponent_moved + your_turn are published
together), and the constant 10s full-lobby poll per client is gone.
This commit is contained in:
Ilia Denisov
2026-06-16 21:06:31 +02:00
parent 12d128f1cc
commit 2a034ff9be
+5 -1
View File
@@ -55,7 +55,11 @@
void load();
});
$effect(() => {
if (app.lastEvent) void load();
// Refetch on a real game event only — not the 10 s keep-alive heartbeat. Refetching on every
// heartbeat turned the lobby into a 10 s poll whose REST view of a just-committed opponent move
// could update (and blink) a card seconds before the matching your_turn event/toast arrived
// over the slower live stream; gating it keeps the card, its blink and the toast on one event.
if (app.lastEvent && app.lastEvent.kind !== 'heartbeat') void load();
});
const myId = $derived(app.session?.userId ?? '');