Convenience method
This commit is contained in:
parent
6a80c05909
commit
64f3e2d8b7
@ -170,15 +170,10 @@ impl<Database: IDatabase, Library> IMusicHoardDatabase for MusicHoard<Database,
|
|||||||
album_id: AlbumIdRef,
|
album_id: AlbumIdRef,
|
||||||
mut info: AlbumInfo,
|
mut info: AlbumInfo,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.update_album_and(
|
self.update_album_and_sort(artist_id.as_ref(), album_id.as_ref(), |album| {
|
||||||
artist_id.as_ref(),
|
|
||||||
album_id.as_ref(),
|
|
||||||
|album| {
|
|
||||||
mem::swap(&mut album.meta.info, &mut info);
|
mem::swap(&mut album.meta.info, &mut info);
|
||||||
album.meta.info.merge_in_place(info);
|
album.meta.info.merge_in_place(info);
|
||||||
},
|
})
|
||||||
|artist| artist.albums.sort_unstable(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_album_info<Id: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
|
fn clear_album_info<Id: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
|
||||||
@ -186,12 +181,9 @@ impl<Database: IDatabase, Library> IMusicHoardDatabase for MusicHoard<Database,
|
|||||||
artist_id: Id,
|
artist_id: Id,
|
||||||
album_id: AlbumIdRef,
|
album_id: AlbumIdRef,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.update_album_and(
|
self.update_album_and_sort(artist_id.as_ref(), album_id.as_ref(), |album| {
|
||||||
artist_id.as_ref(),
|
album.meta.info = AlbumInfo::default()
|
||||||
album_id.as_ref(),
|
})
|
||||||
|album| album.meta.info = AlbumInfo::default(),
|
|
||||||
|artist| artist.albums.sort_unstable(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,6 +262,20 @@ impl<Database: IDatabase, Library> MusicHoard<Database, Library> {
|
|||||||
self.update_collection(|_| {})
|
self.update_collection(|_| {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_album_and_sort<FnAlbum>(
|
||||||
|
&mut self,
|
||||||
|
artist_id: &ArtistId,
|
||||||
|
album_id: &AlbumId,
|
||||||
|
fn_album: FnAlbum,
|
||||||
|
) -> Result<(), Error>
|
||||||
|
where
|
||||||
|
FnAlbum: FnOnce(&mut Album),
|
||||||
|
{
|
||||||
|
self.update_album_and(artist_id, album_id, fn_album, |artist| {
|
||||||
|
artist.albums.sort_unstable()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn update_album<FnAlbum>(
|
fn update_album<FnAlbum>(
|
||||||
&mut self,
|
&mut self,
|
||||||
artist_id: &ArtistId,
|
artist_id: &ArtistId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user