diff --git a/src/components/frontend/flappy/FlappyLeaderboard.tsx b/src/components/frontend/flappy/FlappyLeaderboard.tsx index d59f76e..b1b494c 100644 --- a/src/components/frontend/flappy/FlappyLeaderboard.tsx +++ b/src/components/frontend/flappy/FlappyLeaderboard.tsx @@ -36,6 +36,7 @@ interface LeaderboardRow { bestScore: number; xpEarned: number; isCurrentUser: boolean; + isOutsideTopTen?: boolean; } interface FlappyLeaderboardProps { @@ -60,9 +61,10 @@ export function FlappyLeaderboard({ refreshKey = 0, currentUserId, activePilots setFailed(false); const params = new URLSearchParams({ - "where[progression.minigames.flappyBird.bestScore][greater_than]": "0", sort: "-progression.minigames.flappyBird.bestScore", - limit: "10", + // Fetch enough profiles to keep the current pilot visible even when + // they have not completed a scored run yet. + limit: "100", depth: "1", }); @@ -73,8 +75,7 @@ export function FlappyLeaderboard({ refreshKey = 0, currentUserId, activePilots }) .then((data) => { if (cancelled) return; - setRows( - (data.docs ?? []).map((doc) => { + const mapped: LeaderboardRow[] = (data.docs ?? []).map((doc) => { const flappy = doc.progression?.minigames?.flappyBird ?? {}; const user = typeof doc.user === "object" && doc.user !== null ? doc.user : null; const name = @@ -88,8 +89,14 @@ export function FlappyLeaderboard({ refreshKey = 0, currentUserId, activePilots xpEarned: flappy.xpEarned ?? 0, isCurrentUser: user ? String(user.id) === String(currentUserId) : false, }; - }), - ); + }); + const scored = mapped.filter((row) => row.bestScore > 0); + const visible = scored.slice(0, 10); + const current = mapped.find((row) => row.isCurrentUser); + if (current && !visible.some((row) => row.id === current.id)) { + visible.push({ ...current, isOutsideTopTen: true }); + } + setRows(visible); }) .catch(() => { if (!cancelled) setFailed(true); @@ -141,9 +148,16 @@ export function FlappyLeaderboard({ refreshKey = 0, currentUserId, activePilots
{rows.map((row, i) => ( -