Add shortcut to reload database and/or library #116

Merged
wojtek merged 14 commits from 105---add-shortcut-to-reload-database-and/or-library into main 2024-02-03 14:32:13 +01:00
Showing only changes of commit 42c192bd01 - Show all commits

View File

@ -425,23 +425,23 @@ mod tests {
assert_eq!(sel.state.selected(), Some(tracks.len() - 1)); assert_eq!(sel.state.selected(), Some(tracks.len() - 1));
// Re-initialise. // Re-initialise.
let previous = sel.clone(); let expected = sel.clone();
let active_track = ActiveTrack::get(tracks, &sel); let active_track = ActiveTrack::get(tracks, &sel);
sel.reinitialise(tracks, active_track); sel.reinitialise(tracks, active_track);
assert_eq!(sel, previous); assert_eq!(sel, expected);
// Re-initialise out-of-bounds. // Re-initialise out-of-bounds.
let mut previous = sel.clone(); let mut expected = sel.clone();
previous.decrement(tracks); expected.decrement(tracks);
let active_track = ActiveTrack::get(tracks, &sel); let active_track = ActiveTrack::get(tracks, &sel);
sel.reinitialise(&tracks[..(tracks.len() - 1)], active_track); sel.reinitialise(&tracks[..(tracks.len() - 1)], active_track);
assert_eq!(sel, previous); assert_eq!(sel, expected);
// Re-initialise empty. // Re-initialise empty.
let previous = TrackSelection::initialise(&[]); let expected = TrackSelection::initialise(&[]);
let active_track = ActiveTrack::get(tracks, &sel); let active_track = ActiveTrack::get(tracks, &sel);
sel.reinitialise(&[], active_track); sel.reinitialise(&[], active_track);
assert_eq!(sel, previous); assert_eq!(sel, expected);
// Artifical test case to verify upper limit. // Artifical test case to verify upper limit.
sel.state.select(Some(std::usize::MAX)); sel.state.select(Some(std::usize::MAX));
@ -496,23 +496,23 @@ mod tests {
assert_eq!(sel.track.state.selected(), Some(1)); assert_eq!(sel.track.state.selected(), Some(1));
// Re-initialise. // Re-initialise.
let previous = sel.clone(); let expected = sel.clone();
let active_album = ActiveAlbum::get(albums, &sel); let active_album = ActiveAlbum::get(albums, &sel);
sel.reinitialise(albums, active_album); sel.reinitialise(albums, active_album);
assert_eq!(sel, previous); assert_eq!(sel, expected);
// Re-initialise out-of-bounds. // Re-initialise out-of-bounds.
let mut previous = sel.clone(); let mut expected = sel.clone();
previous.decrement(albums); expected.decrement(albums);
let active_album = ActiveAlbum::get(albums, &sel); let active_album = ActiveAlbum::get(albums, &sel);
sel.reinitialise(&albums[..(albums.len() - 1)], active_album); sel.reinitialise(&albums[..(albums.len() - 1)], active_album);
assert_eq!(sel, previous); assert_eq!(sel, expected);
// Re-initialise empty. // Re-initialise empty.
let previous = AlbumSelection::initialise(&[]); let expected = AlbumSelection::initialise(&[]);
let active_album = ActiveAlbum::get(albums, &sel); let active_album = ActiveAlbum::get(albums, &sel);
sel.reinitialise(&[], active_album); sel.reinitialise(&[], active_album);
assert_eq!(sel, previous); assert_eq!(sel, expected);
// Artifical test case to verify upper limit. // Artifical test case to verify upper limit.
sel.state.select(Some(std::usize::MAX)); sel.state.select(Some(std::usize::MAX));
@ -570,23 +570,23 @@ mod tests {
assert_eq!(sel.album.state.selected(), Some(1)); assert_eq!(sel.album.state.selected(), Some(1));
// Re-initialise. // Re-initialise.
let previous = sel.clone(); let expected = sel.clone();
let active_artist = ActiveArtist::get(artists, &sel); let active_artist = ActiveArtist::get(artists, &sel);
sel.reinitialise(artists, active_artist); sel.reinitialise(artists, active_artist);
assert_eq!(sel, previous); assert_eq!(sel, expected);
// Re-initialise out-of-bounds. // Re-initialise out-of-bounds.
let mut previous = sel.clone(); let mut expected = sel.clone();
previous.decrement(artists); expected.decrement(artists);
let active_artist = ActiveArtist::get(artists, &sel); let active_artist = ActiveArtist::get(artists, &sel);
sel.reinitialise(&artists[..(artists.len() - 1)], active_artist); sel.reinitialise(&artists[..(artists.len() - 1)], active_artist);
assert_eq!(sel, previous); assert_eq!(sel, expected);
// Re-initialise empty. // Re-initialise empty.
let previous = ArtistSelection::initialise(&[]); let expected = ArtistSelection::initialise(&[]);
let active_artist = ActiveArtist::get(artists, &sel); let active_artist = ActiveArtist::get(artists, &sel);
sel.reinitialise(&[], active_artist); sel.reinitialise(&[], active_artist);
assert_eq!(sel, previous); assert_eq!(sel, expected);
// Artifical test case to verify upper limit. // Artifical test case to verify upper limit.
sel.state.select(Some(std::usize::MAX)); sel.state.select(Some(std::usize::MAX));