Skip to content

Commit

Permalink
Use playback.current_source for checking if a playlist is being played
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaedus committed Jun 6, 2023
1 parent c96f544 commit 3c6994c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
9 changes: 6 additions & 3 deletions src/app/components/details/album_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,13 @@ impl AlbumHeaderWidget {
gettext("Play")
};
let tooltip_text = Some(translated_tooltip.as_str());
let playback_control = imp::AlbumHeaderWidget::from_obj(self);

playback_control.play_button.set_icon_name(playback_icon);
playback_control.play_button.set_tooltip_text(tooltip_text);
self.imp()
.play_button
.set_icon_name(playback_icon);
self.imp()
.play_button.
set_tooltip_text(tooltip_text);
}

pub fn set_artwork(&self, art: &gdk_pixbuf::Pixbuf) {
Expand Down
31 changes: 12 additions & 19 deletions src/app/components/details/details_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,27 +197,20 @@ impl PlaylistModel for DetailsModel {
self.state().playback.current_song_id()
}

fn playlist_song_ids(&self) -> Option<Vec<String>> {
if let Some(album) = self.get_album_description() {
let playlist_ids = album
.songs
.songs
.iter()
.map(|song| song.id.clone())
.collect::<Vec<_>>();
return Some(playlist_ids);
}
None
}

fn playlist_is_playing(&self) -> bool {
let current_song_id = self.state().playback.current_song_id();
if current_song_id.is_none() || self.playlist_song_ids().is_none() {
return false;
if let Some(source) = self.state().playback.current_source() {
if let Some(uri) = source.spotify_uri() {
if let Some(album) = self.get_album_description() {
return uri == format!("spotify:album:{}", album.id);
} else {
false
}
} else {
false
}
} else {
false
}
self.playlist_song_ids()
.unwrap()
.contains(&current_song_id.unwrap())
}

fn play_song_at(&self, pos: usize, id: &str) {
Expand Down
4 changes: 0 additions & 4 deletions src/app/components/playlist/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ pub trait PlaylistModel {

fn current_song_id(&self) -> Option<String>;

fn playlist_song_ids(&self) -> Option<Vec<String>> {
None
}

fn playlist_is_playing(&self) -> bool {
false
}
Expand Down

0 comments on commit 3c6994c

Please sign in to comment.