Repository navigation
fix(apple-music): show each playlist's real track count - #910
Conversation
Music's playlist listing returned only ids and names, so every Apple Music playlist, and the synthetic "All songs" row, reached the GUI with track_count 0 and read "Playlist · 0 songs". The playlists op now reads each listed playlist's count (one Apple Event, about 8ms, per playlist) and sizes the library on the first page. A count Music cannot read stays 0, as before. Fixes LargeModGames#891
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
A playlist whose count Music could not read, and "All songs" before the library is sized, still carried track_count 0, which the GUI shows as "Playlist · 0 songs". The Apple Music state now keeps the rows whose count is unknown, and SourcePlaylists.apple_music_uncounted lists them, so the panel shows "Playlist" for those rows. PlaylistInfo.track_count stays a plain number shared by every source.
LargeModGames
left a comment
There was a problem hiding this comment.
A count Music can't read still ends up as 0 songs: p.count.unwrap_or(0) turns the null back into the value #891 is about, and "All songs" keeps its 0 when library is null. Per step 3 of the issue, carry the unknown through to the page so the row shows just Playlist, either with an optional track_count or with an Apple Music rule in the GUI.
|
Thanks! The follow-up commit 913e9a8 does this with an Apple Music rule, keeping |
Summary
Fixes #891. With Apple Music as the source, every playlist in the GUI's Your Library panel, "All songs" included, said
Playlist · 0 songs, because nothing ever asked Music for a count.src/infra/apple_music/music.js: theplaylistsop returnscountwith each playlist (p.tracks.length, one Apple Event per playlist; the bulkmusic.playlists.tracks.lengthanswers 0, so it cannot replace it). The first page also carrieslibrary, the library's own count. A count Music cannot read comes back asnull.src/infra/apple_music/mod.rs:parse_playlistsputscountintotrack_countand returns the library count alongside the page. Both fields are optional, so an older helper's reply still parses.src/infra/apple_music/dispatch.rsandsrc/core/app/apple_music.rs: the first page's library count fills the synthetic "All songs" row (set_apple_music_library_count).PlaylistInfo.track_countstays a plain number shared by every source; instead the Apple Music state keeps the rows whose count is unknown (every page'snullcounts, and "All songs" until the library is sized), andSourcePlaylists.apple_music_uncountedlists them.playlistsForingui/src/libraryModel.tsgives those rows no count, so the panel showsPlaylistinstead ofPlaylist · 0 songs.gui/src/bindings/SourcePlaylists.tsis regenerated.CHANGELOG.md: a line under Unreleased, Fixed.apple_music_playlists_carry_their_track_counts(counts, an unreadable count, the library count only on the first page, an unreadable library),apple_music_all_songs_row_takes_the_library_count(unknown until sized, reset on reload),apple_music_rows_without_a_count_are_listed_as_uncounted(the GUI payload), and aplaylistsForcase ingui/src/libraryModel.test.ts.The terminal sidebar does not print Apple Music counts, so it looks the same as before.
Testing
macOS 27.2 (aarch64), on top of
837308b1:playlistscall took 0.79s.cargo fmt --all --check: clean.cargo clippy --locked -- -D warningson slim (telemetry,tui) and on the macOS CI feature set (withapple-music): clean.cargo clippy --locked -- -D warningsalso on the gui CI feature set and ontelemetryalone: clean.cargo test --locked: default plusapple-music2225 passed, 8 ignored; slim 1721 passed; the gui CI feature set 1914 passed, 8 ignored, and the regenerated bindings are committed.gui/:npm run lint,format:check,typecheck,test(525 passed) andbuild: clean.Summary by CodeRabbit
0; their count is omitted instead.