diff --git a/src/core/musichoard/base.rs b/src/core/musichoard/base.rs index b1775f2..edd63f1 100644 --- a/src/core/musichoard/base.rs +++ b/src/core/musichoard/base.rs @@ -30,7 +30,6 @@ impl IMusicHoardBase for MusicHoard { } pub trait IMusicHoardBasePrivate { - fn sort_artists(collection: &mut [Artist]); fn sort_albums_and_tracks<'a, C: Iterator>(collection: C); fn merge_collections>(&self, database: It) -> Collection; @@ -55,10 +54,6 @@ pub trait IMusicHoardBasePrivate { } impl IMusicHoardBasePrivate for MusicHoard { - fn sort_artists(collection: &mut [Artist]) { - collection.sort_unstable(); - } - fn sort_albums_and_tracks<'a, COL: Iterator>(collection: COL) { for artist in collection { artist.albums.sort_unstable(); diff --git a/src/core/musichoard/database.rs b/src/core/musichoard/database.rs index 24065f8..26a0b71 100644 --- a/src/core/musichoard/database.rs +++ b/src/core/musichoard/database.rs @@ -86,19 +86,11 @@ impl IMusicHoardDatabase for MusicHoard Result<(), Error> { - self.update_artist_and( - artist_id.as_ref(), - |artist| artist.meta.set_mb_ref(mb_ref), - |collection| Self::sort_artists(collection), - ) + self.update_artist(artist_id.as_ref(), |artist| artist.meta.set_mb_ref(mb_ref)) } fn clear_artist_mb_ref>(&mut self, artist_id: Id) -> Result<(), Error> { - self.update_artist_and( - artist_id.as_ref(), - |artist| artist.meta.clear_mb_ref(), - |collection| Self::sort_artists(collection), - ) + self.update_artist(artist_id.as_ref(), |artist| artist.meta.clear_mb_ref()) } fn merge_artist_info>( @@ -157,12 +149,9 @@ impl IMusicHoardDatabase for MusicHoard Result<(), Error> { - self.update_album_and( - artist_id.as_ref(), - album_id.as_ref(), - |album| album.meta.set_mb_ref(mb_ref), - |artist| artist.albums.sort_unstable(), - ) + self.update_album(artist_id.as_ref(), album_id.as_ref(), |album| { + album.meta.set_mb_ref(mb_ref) + }) } fn clear_album_mb_ref, AlbumIdRef: AsRef>( @@ -170,12 +159,9 @@ impl IMusicHoardDatabase for MusicHoard Result<(), Error> { - self.update_album_and( - artist_id.as_ref(), - album_id.as_ref(), - |album| album.meta.clear_mb_ref(), - |artist| artist.albums.sort_unstable(), - ) + self.update_album(artist_id.as_ref(), album_id.as_ref(), |album| { + album.meta.clear_mb_ref() + }) } fn merge_album_info, AlbumIdRef: AsRef>( @@ -184,10 +170,15 @@ impl IMusicHoardDatabase for MusicHoard Result<(), Error> { - self.update_album(artist_id.as_ref(), album_id.as_ref(), |album| { - mem::swap(&mut album.meta.info, &mut info); - album.meta.info.merge_in_place(info); - }) + self.update_album_and( + artist_id.as_ref(), + album_id.as_ref(), + |album| { + mem::swap(&mut album.meta.info, &mut info); + album.meta.info.merge_in_place(info); + }, + |artist| artist.albums.sort_unstable(), + ) } fn clear_album_info, AlbumIdRef: AsRef>( @@ -195,9 +186,12 @@ impl IMusicHoardDatabase for MusicHoard Result<(), Error> { - self.update_album(artist_id.as_ref(), album_id.as_ref(), |album| { - album.meta.info = AlbumInfo::default() - }) + self.update_album_and( + artist_id.as_ref(), + album_id.as_ref(), + |album| album.meta.info = AlbumInfo::default(), + |artist| artist.albums.sort_unstable(), + ) } }