Skip to content

Refetch round leaderboard when round id resolves#287

Open
PunchTheDev wants to merge 1 commit into
mainfrom
punch/round-leaderboard-deps
Open

Refetch round leaderboard when round id resolves#287
PunchTheDev wants to merge 1 commit into
mainfrom
punch/round-leaderboard-deps

Conversation

@PunchTheDev
Copy link
Copy Markdown
Owner

Summary

The Round standings panel on /problems/:roundId and the round-tab leaderboard on /rankings?tab=:roundId were silently invisible on first paint. useApi only re-fires on its internal tick counter, so when the inline fetcher () => round ? api.roundLeaderboard(roundId_) : Promise.resolve(null) ran during initial render — before allRounds had populated and round resolved — it resolved to null and never re-fetched until the 30–60s interval ticked.

This patch extends useApi with an optional deps array and threads [round?.id] / [activeRoundId] through the two call sites that gate their fetcher on a value that arrives asynchronously.

Changes

  • useApi.ts: 3rd param deps: unknown[] = [], spread into the effect deps. Default [] preserves existing call-site behavior for every other caller.
  • App.tsx CategoryPage (/problems/:roundId): pass [round?.id] so the round leaderboard fires the moment the round resolves from allRounds.
  • App.tsx RankingsPage round-tab fetch: pass [activeRoundId] so switching round tabs triggers an immediate fetch, not a 30s wait.
  • BACKLOG.md: Round-level SOTA chart (RoundStandingsPanel) flipped from ○ ○ ○ to ● ● ●.

Verification

Puppeteer at 1440×900:

  • /problems/round_001/rounds/round_001/leaderboard 200 fires immediately; panel renders #1 PunchTheDev · 1/15 · 0.967 (was missing entirely pre-patch, network trace confirmed the request was never made).
  • /rankings?tab=round_001 — same endpoint hit immediately; standings table populated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant