Skip to content

fix: prevent leaderboard rank numbers flashing wrong positions on initial load#570

Open
Priyanka0205-CSE wants to merge 2 commits into
indresh404:mainfrom
Priyanka0205-CSE:fix/leaderboard-rank-flash
Open

fix: prevent leaderboard rank numbers flashing wrong positions on initial load#570
Priyanka0205-CSE wants to merge 2 commits into
indresh404:mainfrom
Priyanka0205-CSE:fix/leaderboard-rank-flash

Conversation

@Priyanka0205-CSE

Copy link
Copy Markdown
Contributor

Fixes #552

Root Cause

The leaderboard uses Firestore onSnapshot which fires twice on page load:

  1. First with cached data (instant) — may be unsorted/stale
  2. Then with server data — correct and authoritative

The loading state was cleared after the first callback (cache), causing rank numbers to flash incorrect positions for 1-2 seconds before jumping to the correct order.

Fix

Added a snapshot.metadata.fromCache check so the loading spinner is only hidden when data arrives from the Firestore server, not from cache.

Change

  • src/pages/GitRank.jsx — wrap setLoadingUsers(false) in if (!snapshot.metadata.fromCache)

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ranker-hub Ready Ready Preview, Comment Jun 17, 2026 5:12am

@github-actions github-actions Bot added backend Backend/Firebase related changes bug Something isn't working enhancement New feature or request frontend Frontend related changes (HTML/CSS/JS/React) gssoc GirlScript Summer of Code gssoc26 GirlScript Summer of Code 2026 nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review labels Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend/Firebase related changes bug Something isn't working enhancement New feature or request frontend Frontend related changes (HTML/CSS/JS/React) gssoc GirlScript Summer of Code gssoc26 GirlScript Summer of Code 2026 nsoc NSoC NSoC'26 NSoC 2026 pending-review PR is pending review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Leaderboard rank numbers flash wrong positions for a second on page load

1 participant