-
Notifications
You must be signed in to change notification settings - Fork 248
feat: sort playlists and albums alphabetically #696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: sort playlists and albums alphabetically #696
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the commands are awkward to use cause you need to focus the right window to initiate the command.
A better way might be defining sort commands for the whole library page. The order can be based on what available in the official app (maybe exclude Creator
):
This also helps avoid confusion cause the command name/description implies users can use it to sort albums/playlists in other pages
I have done this: ,,A better way might be defining sort commands for the whole library page. The order can be based on what available in the official app", but I can't sort exactly like in the app because the API doesn't provide sufficient information. I hope you find this helpful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for updating. Looks much better
spotify_player/src/client/mod.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to change this file. The new field should be handled in the conversion functions defined in spotify_player/src/state/model.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to change the way it converts from album because it was seen as FullAlbum and not as SavedAlbums, but in rest I reverted it back and migrated the logic to model.rs
spotify_player/src/event/page.rs
Outdated
data.user_data.playlists.sort_by(|a, b| { | ||
match (a, b) { | ||
(PlaylistFolderItem::Playlist(p1), PlaylistFolderItem::Playlist(p2)) => { | ||
p1.snapshot_id.cmp(&p2.snapshot_id) // Sort ascending by `snapshot_id` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the correct ordering logic for playlists is comparing current_folder_id
and if two playlists are in different folder, sort them accordingly, e.g
if p1.current_folder_id != p2. current_folder_id {
p1.current_folder_id.cmp(&p2.current_folder_id)
} else {
p1.snapshot_id.cmp(&p2.snapshot_id)
}
I tried implementing your suggestions. Tell me if it needs other changes. Thank you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating, LGTM! I pushed a cleanup commit myself. Also update the keybinds to s l a
and s l r
for consistency with other commands.
Resolves #473
Added functionality to sort items by alphabetical or recently added in the library page.