Skip to content

Commit

Permalink
Small edits
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksongoode committed Dec 25, 2024
1 parent 27c7079 commit eb29495
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
11 changes: 5 additions & 6 deletions psst-gui/src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
1 change: 0 additions & 1 deletion psst-gui/src/data/nav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
Expand Down
21 changes: 8 additions & 13 deletions psst-gui/src/ui/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,15 @@ pub fn playable_widget(track: &Track, display: Display) -> impl Widget<PlayRow<A
.with_child(saved)
.padding(theme::grid(1.0))
.link()
.active(|row: &PlayRow<Arc<Track>>, _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<Arc<Track>>, _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)
Expand Down

0 comments on commit eb29495

Please sign in to comment.