fix(feed): prevent Latest feed from blanking on background refetch#14470
Merged
Conversation
Apply the same staleTime + enabled guard fix that was landed in useForYouFeed (commit 3d65667) to the "Latest" chronological feed hook, which was left behind. Bug 1 — missing staleTime: useFeed had no staleTime, so the react-query default of 0 caused the query to refetch immediately after the first paint on every mount/focus. If that refetch settled empty (transient backend result, or a different validator node in the fleet), react-query replaced the populated feed with `[]`. The lineup reads an empty list as "no content" and renders the empty state, causing the feed to flash and then blank. Fix: staleTime: 5 * 60 * 1000 (5 min, overridable via options). Infinity is used for the For You feed because those results are personalised and session-stable; 5 min is used here because the Latest feed is chronological and users reasonably expect fresh content when they return after a while. Bug 2 — enabled logic override / undefined account: The hook spread ...options after the enabled field, so any options.enabled: false passed by a caller was silently discarded. Worse, the check used !== null (strict), so while the account is still resolving and currentUserId is undefined the query fired, ran the !currentUserId guard inside queryFn, and returned [], caching that empty result under the [feed, undefined] key. A later render could briefly read that key and flash the empty state. Fix: move enabled after ...options with the same guard used in useForYouFeed (options?.enabled !== false && currentUserId != null). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Contributor
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14470.audius.workers.dev Unique preview for this PR (deployed from this branch). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
useFeed was missing staleTime (default 0), so any background refetch returning [] would overwrite a populated feed. Also fixes the enabled override — options.enabled was being silently discarded and currentUserId !== null was firing queries while the account was still loading (undefined), seeding an empty cache entry. Mirrors the fix from 3d65667 applied to useForYouFeed.