Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions spotify_player/src/state/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ impl Album {
artists: from_simplified_artists_to_artists(album.artists),
})
}

/// gets the album's release year
pub fn year(&self) -> String {
self.release_date
.split('-')
.next()
.unwrap_or("")
.to_string()
}
}

impl From<rspotify_model::FullAlbum> for Album {
Expand All @@ -335,9 +344,10 @@ impl std::fmt::Display for Album {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{} • {}",
"{} • {} ({})",
self.name,
map_join(&self.artists, |a| &a.name, ", ")
map_join(&self.artists, |a| &a.name, ", "),
self.year()
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion spotify_player/src/ui/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ fn render_artist_context_page_windows(
let (album_list, n_albums) = {
let album_items = albums
.into_iter()
.map(|a| (a.name.clone(), false))
.map(|a| (format!("{1} • {0}", a.name, a.year()), false))
.collect::<Vec<_>>();

utils::construct_list_widget(
Expand Down