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 48572fe03b - Show all commits

View File

@ -147,17 +147,17 @@ impl ArtistSelection {
fn reinitialise_with_index(
&mut self,
artists: &[Artist],
mut index: usize,
mut active_album: Option<ActiveAlbum>,
index: usize,
active_album: Option<ActiveAlbum>,
) {
if artists.is_empty() {
self.state.select(None);
self.album.reinitialise(&[], None);
self.album = AlbumSelection::initialise(&[]);
} else if index >= artists.len() {
let end = artists.len() - 1;
self.state.select(Some(end));
self.album = AlbumSelection::initialise(&artists[end].albums);
} else {
if index >= artists.len() {
index = artists.len() - 1;
active_album = None;
}
self.state.select(Some(index));
self.album
.reinitialise(&artists[index].albums, active_album);
@ -234,17 +234,17 @@ impl AlbumSelection {
fn reinitialise_with_index(
&mut self,
albums: &[Album],
mut index: usize,
mut active_track: Option<ActiveTrack>,
index: usize,
active_track: Option<ActiveTrack>,
) {
if albums.is_empty() {
self.state.select(None);
self.track = TrackSelection::initialise(&[]);
} else if index >= albums.len() {
let end = albums.len() - 1;
self.state.select(Some(end));
self.track = TrackSelection::initialise(&albums[end].tracks);
} else {
if index >= albums.len() {
index = albums.len() - 1;
active_track = None;
}
self.state.select(Some(index));
self.track.reinitialise(&albums[index].tracks, active_track);
}
@ -303,13 +303,12 @@ impl TrackSelection {
}
}
fn reinitialise_with_index(&mut self, tracks: &[Track], mut index: usize) {
fn reinitialise_with_index(&mut self, tracks: &[Track], index: usize) {
if tracks.is_empty() {
self.state.select(None);
} else if index >= tracks.len() {
self.state.select(Some(tracks.len() - 1));
} else {
if index >= tracks.len() {
index = tracks.len() - 1;
}
self.state.select(Some(index));
}
}