diff --git a/src/app/collection/index.rs b/src/app/collection/index.rs index aa64c5a..7d1c2a3 100644 --- a/src/app/collection/index.rs +++ b/src/app/collection/index.rs @@ -304,17 +304,34 @@ impl Index { pub(self) fn get_artist(&self, artist_id: ArtistID) -> Option { self.artists.get(&artist_id).map(|a| { - let mut albums = a - .albums - .iter() - .filter_map(|album_id| self.get_album(*album_id)) - .collect::>(); + let albums = { + let mut albums = a + .albums + .iter() + .filter_map(|album_id| self.get_album(*album_id)) + .collect::>(); + albums.sort_by(|a, b| (a.year, &a.name).partial_cmp(&(b.year, &b.name)).unwrap()); + albums + }; - albums.sort_by(|a, b| (a.year, &a.name).partial_cmp(&(b.year, &b.name)).unwrap()); + let album_appearances = { + let mut album_appearances = a + .album_appearances + .iter() + .filter_map(|album_id| self.get_album(*album_id)) + .collect::>(); + album_appearances.sort_by(|a, b| { + (&a.artists, a.year, &a.name) + .partial_cmp(&(&b.artists, b.year, &b.name)) + .unwrap() + }); + album_appearances + }; collection::Artist { name: a.name.clone(), - albums: albums, + albums, + album_appearances, } }) } diff --git a/src/app/collection/types.rs b/src/app/collection/types.rs index 4601900..b0180c6 100644 --- a/src/app/collection/types.rs +++ b/src/app/collection/types.rs @@ -68,6 +68,7 @@ pub struct Directory { pub struct Artist { pub name: Option, pub albums: Vec, + pub album_appearances: Vec, } #[derive(Debug, Default, PartialEq, Eq)] diff --git a/src/server/dto/v8.rs b/src/server/dto/v8.rs index 5ca51eb..b8b7cff 100644 --- a/src/server/dto/v8.rs +++ b/src/server/dto/v8.rs @@ -305,6 +305,7 @@ impl From for BrowserEntry { pub struct Artist { pub name: Option, pub albums: Vec, + pub album_appearances: Vec, } impl From for Artist { @@ -312,6 +313,7 @@ impl From for Artist { Self { name: a.name, albums: a.albums.into_iter().map(|a| a.into()).collect(), + album_appearances: a.album_appearances.into_iter().map(|a| a.into()).collect(), } } }