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( fn reinitialise_with_index(
&mut self, &mut self,
artists: &[Artist], artists: &[Artist],
mut index: usize, index: usize,
mut active_album: Option<ActiveAlbum>, active_album: Option<ActiveAlbum>,
) { ) {
if artists.is_empty() { if artists.is_empty() {
self.state.select(None); 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 { } else {
if index >= artists.len() {
index = artists.len() - 1;
active_album = None;
}
self.state.select(Some(index)); self.state.select(Some(index));
self.album self.album
.reinitialise(&artists[index].albums, active_album); .reinitialise(&artists[index].albums, active_album);
@ -234,17 +234,17 @@ impl AlbumSelection {
fn reinitialise_with_index( fn reinitialise_with_index(
&mut self, &mut self,
albums: &[Album], albums: &[Album],
mut index: usize, index: usize,
mut active_track: Option<ActiveTrack>, active_track: Option<ActiveTrack>,
) { ) {
if albums.is_empty() { if albums.is_empty() {
self.state.select(None); self.state.select(None);
self.track = TrackSelection::initialise(&[]); 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 { } else {
if index >= albums.len() {
index = albums.len() - 1;
active_track = None;
}
self.state.select(Some(index)); self.state.select(Some(index));
self.track.reinitialise(&albums[index].tracks, active_track); 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() { if tracks.is_empty() {
self.state.select(None); self.state.select(None);
} else if index >= tracks.len() {
self.state.select(Some(tracks.len() - 1));
} else { } else {
if index >= tracks.len() {
index = tracks.len() - 1;
}
self.state.select(Some(index)); self.state.select(Some(index));
} }
} }