fix(playlist): allow removing the last track from a playlist#14306
Merged
Conversation
The trash icon on each row in the edit-collection form was disabled whenever only one track remained. That guard makes sense for the upload flow (which reuses the same component) but blocked edits to existing playlists from ever emptying out. Thread `isUpload` through `CollectionTrackFieldArray` so the guard only applies during upload. Even via the kebab menu's "Remove from playlist" path, the removal of the final track confirmed client-side but reappeared on reload. In the discovery-provider entity manager, `populate_playlist_record_metadata` was using a truthiness check on `playlist_metadata["playlist_contents"]` — an empty list (the SDK's serialization for "no tracks") is falsy in Python, so the field was silently treated as omitted. Compare with `is None` instead so an explicit empty list is applied. `update_playlist_tracks` already handles an empty `track_ids` correctly (marks all existing rows removed). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Contributor
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14306.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
CollectionTrackFieldArraywas disabled whenever only one track remained. That guard fits the upload flow (which reuses the same form) but blocked edits to existing playlists from ever emptying out.isUploadnow flows through fromEditCollectionForm, so the guard only applies during upload.populate_playlist_record_metadata, a Python truthiness check onplaylist_metadata["playlist_contents"]treated the SDK's empty-array payload ([]) as if the field were omitted and silently skipped the update. Switched tois Noneso an explicit empty list is applied. Downstreamupdate_playlist_tracksalready handles an emptytrack_idscorrectly (marks all existing rows removed).Repro
Also: open the same playlist via "Edit Playlist" — the trash icon on the only row was disabled.
Test plan
playlist_contents: {"track_ids": []}(legacy dict form, used in existing tests) continues to update correctly.🤖 Generated with Claude Code