fix(events): prevent follow button flash on contest page#14508
Open
dylanjeffers wants to merge 1 commit into
Open
fix(events): prevent follow button flash on contest page#14508dylanjeffers wants to merge 1 commit into
dylanjeffers wants to merge 1 commit into
Conversation
The contest follow button briefly rendered "Follow" (unfollowed) before snapping to "Following" for users who already follow the contest. The flash happened because the button defaulted to the unfollowed state while useEventFollowState was still in-flight (data: undefined -> isFollowed false -> true once resolved). Gate the visible follow button on the query's isPending state: while loading, render a spinner-only button (fixed width keeps layout stable) instead of the misleading "Follow" label, on both the desktop web page and the React Native contest screen. Mobile web hides follow inside an overflow menu, so it has no visible flash and is left unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Contributor
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14508.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.
Summary
Small UX nit reported by Ray in Slack: when loading a contest page, the Follow button briefly flashes "Follow" (unfollowed state) before snapping to "Following" for users who already follow the contest.
Cause
The button derived its state from
useEventFollowStatewithconst isFollowed = !!followState?.isFollowed. While the query is in-flightfollowStateisundefined, soisFollowedevaluates tofalseand the button renders the unfollowed "Follow" state — then re-renders to "Following" once the query resolves.Note: a
placeholderData/staleTimetweak on the query does not fix this — React Query already returns cached data immediately, so the flash only happens on a genuine first load with no cache. The real fix is to not commit to a label until the data resolves.Fix
Gate the visible follow button on the query's
isPendingstate. While loading, render a spinner-only button (the fixed width keeps layout stable) instead of the misleading "Follow" label:packages/web/.../desktop/ContestPage.tsx—isLoading={isFollowStatePending}, empty label while pending.packages/mobile/.../contest-screen/ContestScreen.tsx— same treatment on the RN button.components/mobile/ContestPage.tsx) hides follow inside an overflow kebab menu, so there's no visible flash on load — left unchanged.Test
Added a regression test to
ContestPage.test.tsxasserting that neither "Follow" nor "Following" renders while the follow state is still loading. Full contest-page suite passes (7/7).🤖 Generated with Claude Code