fix(web): seed contest source track from URL when permalink resolves#14370
Merged
Conversation
On the track-scoped Host Remix Contest route (/:handle/:slug/host-contest), the URL identifies the source track, but useTrackByPermalink resolves asynchronously. The useState initializer for sourceTrackIds ran before the resolve, captured primaryTrackId as undefined, and seeded the array to []. The Source Track section then rendered "+ Add Track" instead of the URL's track, and the Launch button stayed disabled (sourceTrackIds.length === 0) — so clicking Launch produced no action, error, or modal. Regression introduced in #14174, which added the source-track-required gate to the Launch button's disabled check. Fix by syncing sourceTrackIds once when primaryTrackId first resolves, guarded against overwriting drafts, existing-contest hydration, and user removals. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Contributor
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14370.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
Clicking Launch on the Host Remix Contest page produced no action, error, or modal when the user entered via the track-scoped route (
/:handle/:slug/host-contest) — e.g. via the Host Remix Contest overflow-menu item on a track tile.Root cause
useTrackByPermalink(...)resolves asynchronously, but the form seedssourceTrackIdsviauseState(... primaryTrackId ? [primaryTrackId] : []).useStateinitializers only run on first mount, and on first mountprimaryTrackId === undefined— sosourceTrackIdsstarted empty and there was nouseEffectto sync it once the track resolved. The Source Track section then rendered "+ Add Track" instead of the URL's track, and the Launch button stayed disabled (sourceTrackIds.length === 0).The async race existed since #14151, but the visible breakage was introduced in #14174 when
sourceTrackIds.length === 0was added to the Launch button'sdisabledcheck.Fix
Add a one-shot
useEffectthat seedssourceTrackIdsfromprimaryTrackIdwhen it first resolves. Guarded by a ref so it:sourceTrackIds.length > 0exits early),Test plan
/{handle}/{slug}/host-contestpage, the SOURCE TRACK section should show the URL's track instead of the + Add Track button./{handle}/contest/{slug}./host-contestfrom the Contests page) still requires a manual pick and behaves unchanged.event_data.sourceTrackIdsand is unaffected.Note: I could not browser-verify locally — the page is gated by
useRequiresAccount()and reproducing the bug requires being signed in as the track's owner on a real (prod-data) track. The change typechecks clean.🤖 Generated with Claude Code