From 1a6a5b228418eb21c259f619f221fdee1e57d501 Mon Sep 17 00:00:00 2001 From: Thang Pham Date: Sun, 1 Dec 2024 15:15:43 -0500 Subject: [PATCH 1/3] fix tracks context not playbable --- spotify_player/src/event/window.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/spotify_player/src/event/window.rs b/spotify_player/src/event/window.rs index 132a56a6..9d2fd5c7 100644 --- a/spotify_player/src/event/window.rs +++ b/spotify_player/src/event/window.rs @@ -181,16 +181,19 @@ pub fn handle_command_for_focused_context_window( ), } } - Context::Album { tracks, .. } - | Context::Playlist { tracks, .. } - | Context::Tracks { tracks, .. } => handle_command_for_track_table_window( - command, - client_pub, - Some(context_id.clone()), - tracks, - &data, - ui, - ), + Context::Tracks { tracks, .. } => { + handle_command_for_track_table_window(command, client_pub, None, tracks, &data, ui) + } + Context::Album { tracks, .. } | Context::Playlist { tracks, .. } => { + handle_command_for_track_table_window( + command, + client_pub, + Some(context_id.clone()), + tracks, + &data, + ui, + ) + } Context::Show { show, episodes } => handle_command_for_episode_table_window( command, client_pub, From d2718b25be44f878dd815ee753000c23f51fc22e Mon Sep 17 00:00:00 2001 From: Thang Pham Date: Sun, 1 Dec 2024 15:21:14 -0500 Subject: [PATCH 2/3] update handling codes to be more explicit --- spotify_player/src/event/window.rs | 35 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/spotify_player/src/event/window.rs b/spotify_player/src/event/window.rs index 9d2fd5c7..e99f449a 100644 --- a/spotify_player/src/event/window.rs +++ b/spotify_player/src/event/window.rs @@ -181,19 +181,16 @@ pub fn handle_command_for_focused_context_window( ), } } - Context::Tracks { tracks, .. } => { - handle_command_for_track_table_window(command, client_pub, None, tracks, &data, ui) - } - Context::Album { tracks, .. } | Context::Playlist { tracks, .. } => { - handle_command_for_track_table_window( - command, - client_pub, - Some(context_id.clone()), - tracks, - &data, - ui, - ) - } + Context::Album { tracks, .. } + | Context::Playlist { tracks, .. } + | Context::Tracks { tracks, .. } => handle_command_for_track_table_window( + command, + client_pub, + Some(context_id.clone()), + tracks, + &data, + ui, + ), Context::Show { show, episodes } => handle_command_for_episode_table_window( command, client_pub, @@ -307,10 +304,14 @@ fn handle_command_for_track_table_window( filtered_tracks[id].id.uri() }; - let base_playback = if let Some(context_id) = context_id { - Playback::Context(context_id, None) - } else { - Playback::URIs(tracks.iter().map(|t| t.id.clone().into()).collect(), None) + let base_playback = match context_id { + None | Some(ContextId::Tracks(_)) => { + Playback::URIs(tracks.iter().map(|t| t.id.clone().into()).collect(), None) + } + Some(ContextId::Show(_)) => unreachable!( + "show context should be handled by handle_command_for_episode_table_window" + ), + Some(context_id) => Playback::Context(context_id, None), }; client_pub.send(ClientRequest::Player(PlayerRequest::StartPlayback( From afb64ebffebd4fc7812c6873384911578893716e Mon Sep 17 00:00:00 2001 From: Thang Pham Date: Sun, 1 Dec 2024 15:24:28 -0500 Subject: [PATCH 3/3] bump app's version to 0.20.3 --- Cargo.lock | 2 +- spotify_player/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cb61828f..c8790fdb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5156,7 +5156,7 @@ dependencies = [ [[package]] name = "spotify_player" -version = "0.20.2" +version = "0.20.3" dependencies = [ "anyhow", "async-trait", diff --git a/spotify_player/Cargo.toml b/spotify_player/Cargo.toml index 04776001..b036ba75 100644 --- a/spotify_player/Cargo.toml +++ b/spotify_player/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spotify_player" -version = "0.20.2" +version = "0.20.3" authors = ["Thang Pham "] edition = "2021" license = "MIT"