bugfix: don't panic when an invalid index is to be played

this can be triggered by commands or when hitting return in an empty queue
view. we shouldn't crash in that case..
This commit is contained in:
Henrik Friedrichsen
2019-03-24 13:23:45 +01:00
parent 2a7770177b
commit 0807f6464f

View File

@@ -106,12 +106,13 @@ impl Queue {
}
pub fn play(&self, index: usize) {
let track = &self.queue.read().unwrap()[index];
self.spotify.load(&track);
let mut current = self.current_track.write().unwrap();
current.replace(index);
self.spotify.play();
self.spotify.update_track();
if let Some(track) = &self.queue.read().unwrap().get(index) {
self.spotify.load(&track);
let mut current = self.current_track.write().unwrap();
current.replace(index);
self.spotify.play();
self.spotify.update_track();
}
}
pub fn toggleplayback(&self) {