Skip to content

fix(mobile): stop Trending from reshuffling after a cold start - #14698

Open
dylanjeffers wants to merge 2 commits into
mainfrom
fix/trending-stale-restore-flash
Open

dylanjeffers wants to merge 2 commits into
mainfrom
fix/trending-stale-restore-flash

Conversation

@dylanjeffers

Copy link
Copy Markdown
Contributor

On a cold start, mobile Trending painted the saved snapshot from disk, which can be up to 24 hours old, then refetched and swapped in the current order. Every tile then remounted because lineup keys included the row index, so the list looked like it reloaded into a different UI.

Changes

  • TrendingLineup: if the restored snapshot was already stale when the session started (older than the 5-minute staleTime), show skeletons until the mount refetch lands. If that refetch fails, the snapshot is shown. A snapshot that is still fresh paints right away as before. Refetches later in the session (window focus, etc.) never hold, because their data is newer than the session start.
  • useTrending: also returns isRefetching and dataUpdatedAt.
  • TrackLineup: tile keys are track-<id> / collection-<id> (with a suffix if an entity repeats) instead of including the index, so a reorder moves tiles instead of rebuilding them.
  • TrackLineup: trailing skeletons show only for a load-more the list triggered, not for any background refetch. An empty list that is fetching still shows the initial skeletons.

Testing

  • Ran @tanstack/query-core directly against a hydrated snapshot, with the same _optimisticResults: 'optimistic' that useBaseQuery sets:
    • 2h-old snapshot: the hold is on from the first render and releases when fresh data lands.
    • 1-min-old snapshot: never holds.
    • fetchNextPage: never holds.
  • eslint is clean on the three files, and tsc reports no errors in them. Other tsc errors in the worktree come from node_modules cloned from an older checkout.
  • Not run on a device or simulator.

🤖 Generated with Claude Code

Trending painted the persisted snapshot (up to 24h old), then refetched
and swapped in the current order, remounting every tile because keys
included the row index.

- Hold skeletons while a snapshot that was stale at session start
  refetches; fresh snapshots still paint instantly.
- Key lineup tiles by entity id so a reorder moves tiles.
- Only show trailing skeletons for a load-more, not background refetches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 584f93c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant