From eb294956f507211789d0b2f33f0edc1bca9a060f Mon Sep 17 00:00:00 2001 From: Jackson Goode Date: Wed, 25 Dec 2024 02:17:34 -0800 Subject: [PATCH] Small edits --- psst-gui/src/data/mod.rs | 11 +++++------ psst-gui/src/data/nav.rs | 1 - psst-gui/src/ui/track.rs | 21 ++++++++------------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/psst-gui/src/data/mod.rs b/psst-gui/src/data/mod.rs index 1b4148ff..3262395f 100644 --- a/psst-gui/src/data/mod.rs +++ b/psst-gui/src/data/mod.rs @@ -179,12 +179,11 @@ impl AppState { impl AppState { pub fn navigate(&mut self, nav: &Nav) { - if &self.nav != nav { - let previous: Nav = mem::replace(&mut self.nav, nav.to_owned()); - self.history.push_back(previous); - self.config.last_route.replace(nav.to_owned()); - - Arc::make_mut(&mut self.common_ctx).nav = nav.to_owned(); + if nav != &self.nav { + self.history.push_back(self.nav.clone()); + self.config.last_route.replace(nav.clone()); + self.nav = nav.clone(); + Arc::make_mut(&mut self.common_ctx).nav = nav.clone(); } } diff --git a/psst-gui/src/data/nav.rs b/psst-gui/src/data/nav.rs index a97ed594..3b72137b 100644 --- a/psst-gui/src/data/nav.rs +++ b/psst-gui/src/data/nav.rs @@ -105,7 +105,6 @@ impl SpotifyUrl { let mut segments = url.path_segments()?; let entity = segments.next()?; let id = segments.next()?; - log::info!("url: {:?}", url); match entity { "playlist" => Some(Self::Playlist(id.into())), "artist" => Some(Self::Artist(id.into())), diff --git a/psst-gui/src/ui/track.rs b/psst-gui/src/ui/track.rs index a6687895..c51c05b6 100644 --- a/psst-gui/src/ui/track.rs +++ b/psst-gui/src/ui/track.rs @@ -178,20 +178,15 @@ pub fn playable_widget(track: &Track, display: Display) -> impl Widget>, _env: &Env| match &row.ctx.nav { - Nav::AlbumDetail(_, Some(target_id)) => *target_id == row.item.id, - _ => { - if row.is_playing { - true - } else if let Some(playable) = &row.ctx.now_playing { - match playable { - Playable::Track(track) => track.id == row.item.id, - _ => false, - } - } else { - false - } + .active(|row: &PlayRow>, _env: &Env| { + // Check if this track is the target of album detail navigation + if let Nav::AlbumDetail(_, Some(target_id)) = &row.ctx.nav { + return *target_id == row.item.id; } + // Otherwise check if it's playing or is the current track + row.is_playing || row.ctx.now_playing.as_ref().map_or(false, |playable| { + matches!(playable, Playable::Track(track) if track.id == row.item.id) + }) }) .rounded(theme::BUTTON_BORDER_RADIUS) .context_menu(track_row_menu)