[PR #939] [MERGED] refactor: consolidate client requests and move currently_playing_tracks_id to PlayerState #934

Closed
opened 2026-03-03 00:01:31 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/aome510/spotify-player/pull/939
Author: @aome510
Created: 2/23/2026
Status: Merged
Merged: 2/23/2026
Merged by: @aome510

Base: masterHead: simplify-context-id


📝 Commits (3)

  • f681eff move currently_playing_tracks_id from UIState to PlayerState
  • 98b6f13 simplify codes by using single GetContext request
  • f7fec41 fmt

📊 Changes

11 files changed (+114 additions, -172 deletions)

View changed files

📝 spotify_player/src/client/handlers.rs (+1 -8)
📝 spotify_player/src/client/mod.rs (+43 -80)
📝 spotify_player/src/client/request.rs (+0 -7)
📝 spotify_player/src/event/mod.rs (+32 -37)
📝 spotify_player/src/event/page.rs (+2 -2)
📝 spotify_player/src/event/window.rs (+12 -6)
📝 spotify_player/src/main.rs (+3 -1)
📝 spotify_player/src/state/constant.rs (+8 -8)
📝 spotify_player/src/state/player.rs (+10 -2)
📝 spotify_player/src/state/ui/mod.rs (+0 -18)
📝 spotify_player/src/state/ui/page.rs (+3 -3)

📄 Description

Summary

This PR simplifies the client request model by consolidating multiple specialized track-fetching requests into the single existing GetContext request, and moves currently_playing_tracks_id from UIState to PlayerState.

Consolidate ClientRequest variants

Removed GetUserSavedTracks, GetUserTopTracks, GetUserRecentlyPlayedTracks, and GetRadioTracks request variants. All of these are now dispatched as GetContext(ContextId::Tracks(...)). The handler resolves the appropriate API call by pattern-matching on the tracks URI string (USER_TOP_TRACKS_URI, USER_RECENTLY_PLAYED_TRACKS_URI, USER_LIKED_TRACKS_URI, or a radio: prefixed URI).

Move currently_playing_tracks_id to PlayerState

The field tracking the active Tracks context (for contexts not represented in Spotify's playback API, e.g. liked/top tracks) was moved from UIState to PlayerState. This makes it accessible to PlayerState::playing_context_id(), which now falls back to currently_playing_tracks_id when there is no active Spotify context. All event handler functions that modify this field were updated to take &SharedState instead of using UIStateGuard.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/aome510/spotify-player/pull/939 **Author:** [@aome510](https://github.com/aome510) **Created:** 2/23/2026 **Status:** ✅ Merged **Merged:** 2/23/2026 **Merged by:** [@aome510](https://github.com/aome510) **Base:** `master` ← **Head:** `simplify-context-id` --- ### 📝 Commits (3) - [`f681eff`](https://github.com/aome510/spotify-player/commit/f681eff29e922095511f21da9db016e512b9e4c7) move currently_playing_tracks_id from UIState to PlayerState - [`98b6f13`](https://github.com/aome510/spotify-player/commit/98b6f1328be8479c1a4c88bf6e568a8e99fba7b9) simplify codes by using single GetContext request - [`f7fec41`](https://github.com/aome510/spotify-player/commit/f7fec4113fbc50b548319ad6cb8496d830e49ee5) fmt ### 📊 Changes **11 files changed** (+114 additions, -172 deletions) <details> <summary>View changed files</summary> 📝 `spotify_player/src/client/handlers.rs` (+1 -8) 📝 `spotify_player/src/client/mod.rs` (+43 -80) 📝 `spotify_player/src/client/request.rs` (+0 -7) 📝 `spotify_player/src/event/mod.rs` (+32 -37) 📝 `spotify_player/src/event/page.rs` (+2 -2) 📝 `spotify_player/src/event/window.rs` (+12 -6) 📝 `spotify_player/src/main.rs` (+3 -1) 📝 `spotify_player/src/state/constant.rs` (+8 -8) 📝 `spotify_player/src/state/player.rs` (+10 -2) 📝 `spotify_player/src/state/ui/mod.rs` (+0 -18) 📝 `spotify_player/src/state/ui/page.rs` (+3 -3) </details> ### 📄 Description ## Summary This PR simplifies the client request model by consolidating multiple specialized track-fetching requests into the single existing `GetContext` request, and moves `currently_playing_tracks_id` from `UIState` to `PlayerState`. ### Consolidate `ClientRequest` variants Removed `GetUserSavedTracks`, `GetUserTopTracks`, `GetUserRecentlyPlayedTracks`, and `GetRadioTracks` request variants. All of these are now dispatched as `GetContext(ContextId::Tracks(...))`. The handler resolves the appropriate API call by pattern-matching on the tracks URI string (`USER_TOP_TRACKS_URI`, `USER_RECENTLY_PLAYED_TRACKS_URI`, `USER_LIKED_TRACKS_URI`, or a `radio:` prefixed URI). ### Move `currently_playing_tracks_id` to `PlayerState` The field tracking the active Tracks context (for contexts not represented in Spotify's playback API, e.g. liked/top tracks) was moved from `UIState` to `PlayerState`. This makes it accessible to `PlayerState::playing_context_id()`, which now falls back to `currently_playing_tracks_id` when there is no active Spotify context. All event handler functions that modify this field were updated to take `&SharedState` instead of using `UIStateGuard`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 00:01:31 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-player#934
No description provided.