refactor(c7): migrate recently-played to domain CursorPaged<TrackInfo>#319
Merged
Merged
Conversation
…Info> Remove rspotify PlayHistory from App state. The recently-played field now holds CursorPaged<TrackInfo> (source-agnostic domain type). Conversion from CursorBasedPage<PlayHistory> happens at the infra boundary in get_recently_played via map_cursor_page. UI and handler code read TrackInfo fields directly. Also fix a latent index-misalignment bug in the Key::Enter handler: the old code mapped all items (typed TrackId, infallible), but the new code must re-parse String ids and filter_map drops tracks without valid ids (local files). The playback offset now tracks the remapped position in the filtered uri list rather than passing the raw cursor index unchanged.
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
rspotify::model::PlayHistoryfromapp.recently_playedinsrc/core/app.rs; field now holdsSpotifyResultAndSelectedIndex<Option<CursorPaged<TrackInfo>>>using the Wave 0 domain pagination typeCursorBasedPage<PlayHistory>toCursorPaged<TrackInfo>happens at the infra boundary inget_recently_played(src/infra/network/user.rs) via the foundationmap_cursor_pagehelperdraw_recently_played_table(src/tui/ui/tables.rs) readsTrackInfofields directly (id,name,artists.join(", "),duration_ms)src/tui/handlers/recently_played.rs) re-parses stored String ids toTrackId/PlayableIdat dispatch sites as per architecture specBug fix included
The
Key::Enterhandler previously built atrack_urisvec withfilter_map(dropping tracks withNoneids, e.g. local files common in the recently-played API response) but passed the rawapp.recently_played.indexas the playback offset into the now-shorter vec. This caused the wrong track to start playing when any local file appeared before the cursor position. The fix remaps the offset to the compressed uri list position usingenumerate.Test plan
cargo clippy --no-default-features --features telemetry -- -D warningspasses cleancargo test --no-default-features --features telemetry261 tests passcargo build(full) compilescargo fmt --allapplied