brackt/app/routes/leagues
Chris Parsons 0ac9ef4ff8
fix: eliminate queue tab flash on mobile by using useSyncExternalStore (#46)
* fix: eliminate queue tab flash on mobile by using useSyncExternalStore

useMediaQuery initialized to false and updated in useEffect, causing a
paint where isMobile was false on mobile devices. This rendered the
desktop layout first, hiding the queue tab until the effect fired.

useSyncExternalStore reads matchMedia synchronously on the client so
the correct layout is used on the first render with no extra paint.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: revalidate draft room when Clerk JWT expires at load time

Clerk's short-lived JWTs (~1 min) can expire between navigations.
Server-side clerkMiddleware can't refresh them for client-side loader
fetches, so getAuth() returns userId=null — causing userTeam=undefined,
the queue button to disappear, and the tab to default to "board".

Added a useEffect that detects the mismatch: if the Clerk client SDK
has a valid userId but the loader ran without one, trigger revalidate()
so the loader re-runs with a fresh token and returns correct
userTeam/userQueue data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: prevent infinite revalidation loop in auth guard

If the server consistently fails to populate currentUserId after JWT
refresh (e.g. misconfigured CLERK_SECRET_KEY), the previous effect
would loop indefinitely. A one-shot ref ensures we attempt auth
recovery at most once per mount.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 09:54:14 -08:00
..
__tests__ Claude/redesign autodraft queue c4 kp r (#40) 2026-02-27 22:16:26 -08:00
$leagueId.draft-board.$seasonId.tsx Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
$leagueId.draft.$seasonId.tsx fix: eliminate queue tab flash on mobile by using useSyncExternalStore (#46) 2026-02-28 09:54:14 -08:00
$leagueId.server.ts Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
$leagueId.settings.tsx fix: address code review issues from draft board scrolling and team creation changes (#35) 2026-02-24 10:01:27 -08:00
$leagueId.sports-seasons.$sportsSeasonId.server.ts Fix sports season page 404 when sports season is linked to multiple leagues (#10) 2026-02-20 11:35:35 -08:00
$leagueId.sports-seasons.$sportsSeasonId.tsx feat: Add routes and components for sports season display, including playoff brackets and standings 2025-11-12 23:44:33 -08:00
$leagueId.standings.$seasonId.teams.$teamId.tsx feat: Implement team breakdown pages with detailed score breakdown 2025-11-14 20:01:21 -08:00
$leagueId.standings.$seasonId.tsx Claude/fix pick timer ghll n (#29) 2026-02-22 19:29:29 -08:00
$leagueId.tsx feat: show live draft alert banner on league page (#42) 2026-02-27 23:00:42 -08:00
new.tsx Add implementation plan for commissioner-without-team feature (#6) 2026-02-20 08:45:09 -08:00