Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #464 by adding full date to display next to albums #474

Merged
merged 3 commits into from
Jun 28, 2024
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
12 changes: 2 additions & 10 deletions spotify_player/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1538,21 +1538,13 @@ impl Client {

/// Process a list of albums, which includes
/// - sort albums by the release date
/// - remove albums with duplicated names
fn process_artist_albums(&self, albums: Vec<Album>) -> Vec<Album> {
let mut albums = albums.into_iter().collect::<Vec<_>>();

albums.sort_by(|x, y| x.release_date.partial_cmp(&y.release_date).unwrap());

// use a HashSet to keep track albums with the same name
let mut seen_names = std::collections::HashSet::new();
albums.reverse();

albums.into_iter().rfold(vec![], |mut acc, a| {
if !seen_names.contains(&a.name) {
seen_names.insert(a.name.clone());
acc.push(a);
}
acc
})
albums
}
}
2 changes: 1 addition & 1 deletion spotify_player/src/ui/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ fn render_artist_context_page_windows(
let (album_list, n_albums) = {
let album_items = albums
.into_iter()
.map(|a| (format!("{1} • {0}", a.name, a.year()), false))
.map(|a| (format!("{1} • {0}", a.name, a.release_date), false))
.collect::<Vec<_>>();

utils::construct_list_widget(
Expand Down
Loading