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:
13
src/queue.rs
13
src/queue.rs
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user