brackt/app/hooks
Chris Parsons 6dfe56e178
fix: fully sync local draft state after socket reconnection (#41)
On reconnect, revalidate() re-fetches fresh loader data but the local
useState copies (picks, currentPick, isPaused, isDraftComplete, queue)
never synced with the new values — leaving the UI stale until a manual
refresh.

- Watch revalidatorState (idle→loading→idle) to detect when a
  revalidation completes and apply the fresh loader snapshot to all
  affected local state
- Buffer pick-made socket events received during the revalidation window
  (instead of discarding or double-applying them); merge into the DB
  snapshot on completion, deduplicated by pick ID
- Keep setCurrentPick paired with setPicks in handlePickMade so the
  "on the clock" indicator and the picks list never desync
- Sync queue state from fresh userQueue after revalidation so
  participants drafted while the user was away disappear from their
  queue even if the participant-removed-from-queues events were missed

Adds useDraftSocket reconnect test suite (9 tests) covering initial
connect, socket reconnect, visibility-change triggering, network
flapping, error exhaustion, and cleanup.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 22:50:46 -08:00
..
__tests__ fix: fully sync local draft state after socket reconnection (#41) 2026-02-27 22:50:46 -08:00
useDraftNotifications.ts Add browser push notifications toggle to draft page (#11) 2026-02-20 19:30:53 -08:00
useDraftSocket.ts Fix draft state not updating when returning from backgrounded mobile app (#39) 2026-02-25 09:36:52 -08:00
useMediaQuery.ts Make draft room fully usable on mobile (#30) 2026-02-22 22:36:12 -08:00