feat: sort playlist tracks by title, artist, or duration - #369
Closed
tsibog wants to merge 3 commits into
Closed
Conversation
- Move the sort control into the header action row, right-aligned after the Play/Queue buttons, instead of a separate row above the track list. - Rename the 'Custom order' option to 'Default'. - Give each track row a stable identity (song id + occurrence, numbered in playlist order to keep duplicates distinct) so re-sorting moves rows in place instead of swapping slot contents — the latter reloaded row artwork and like/dislike state, causing the blink and lag on sort changes. - displayedTracks now derives from the identified rows so playback order stays in sync with the displayed order.
Contributor
Author
|
Closing in favor of #375. The sort feature works, but placing the sort control in the header action row causes scroll/hover jank (ViewThatFits re-measuring under the ScrollView). Handing the placement/design decision to a maintainer — details, root-cause bisect, and options in #375. 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.
Description
Adds a sort control to the playlist detail page. Tracks can be sorted by Title, Artist, or Duration (selecting the active option again toggles ascending/descending), with Custom order (the playlist's own order) as the default. The sorted order drives everything consistently: the visible list, row taps, and the header Play / Play Next / Add to Queue actions. Sorting is session-only view state — it never mutates the playlist.
"Date added" was considered and dropped: the
browseresponse forVL<playlistId>carries no per-track added date and the API exposes no server-side sort for playlist contents (only library-level listings support anorderparam).AI Prompt (Optional)
🤖 AI Prompt Used
AI Tool: Claude Code
Type of Change
Related Issues
None found.
Changes Made
PlaylistTrackSortOption+sortOption/sortAscending/displayedTracks/selectSort(_:)onPlaylistDetailViewModel— all sorting logic lives behind this small surface (localized standard compare, artist ties broken by title, nil durations always last, direction toggle on re-select)PlaylistDetailView+TrackSort.swift— compact trailing sortMenuabove the track list (checkmark + direction chevron on the active option), hidden for playlists with fewer than 2 tracksPlaylistDetailView/+HeaderActionsconsumedisplayedTracksso display and playback order always match; the deferred full-playlist load now diffs queued tracks byvideoIdinstead of a fixed count so a re-sort during pagination can't drop or duplicate tracksTesting
swift test --skip KasetUITests)Checklist
swiftlint --strict && swiftformat .PlaylistDetailViewModelTestscovering each option, direction toggle, artist tiebreak, nil-duration ordering)Screenshots
Additional Notes
Includes the same
test:deflake commit as #363/#364 (theNotificationServiceTestsfixed-wait flake lives onmainand hits fresh branches); it disappears on rebase once any of them merges.Agent Transcript
Redacted agent session transcript (scoped to this PR)