fix(albums): page through full tracklist instead of capping at 50#339
Merged
Conversation
Spotify returns album tracks 50 per page. All three paths into the AlbumTracks screen only ever used the first page: get_album_tracks fetched a single page, get_album trusted the first-page tracklist embedded in FullAlbum, and the saved-albums library rendered the same capped cache from me/albums. Albums longer than 50 tracks were silently cut off. Add a pagination loop that follows `next` until the tracklist is complete, extend FullAlbum's embedded page before mapping, and make the saved-albums Enter handler refetch via GetAlbum when the cached tracklist is shorter than total_tracks. Closes #324
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
Albums with more than 50 tracks were cut off because every path into the AlbumTracks screen only used the first page Spotify returns:
get_album_tracks(search results, artist discography, go-to-album from a track) fetched a single page of 50 with a literalTODO: Handle paginationcommentget_albumtrusted the tracklist embedded inFullAlbum, which is silently just the first pageme/albumsThis adds a
fetch_album_tracks_fromhelper that followsnextuntil the tracklist is complete (mirroring the existing artist-albums pagination loop), extendsFullAlbum's embedded page before mapping to the domain type, and makes the saved-albums Enter handler refetch viaGetAlbumwhen the cached tracklist is shorter thantotal_tracks. Complete albums still open instantly from cache.Closes #324
Testing
cargo fmt --allcargo clippy --no-default-features --features telemetry -- -D warningscargo test --no-default-features --features telemetry(351 passed, includes 2 new regression tests for the cache-vs-refetch decision)cargo check(full features)