diff --git a/src/player/player.rs b/src/player/player.rs index 12448a0..8f52e5e 100644 --- a/src/player/player.rs +++ b/src/player/player.rs @@ -55,7 +55,7 @@ impl Player { PlayerEvent::FFTBins(bins) => self.tui_root.metadata.update_spectrogram(bins), } } - if self.playlist.last_song() { + if self.playlist.last_song() && !self.playlist.fetch_queued { self.api_chan.send(APIEvent::FetchRandom)?; } Ok(()) diff --git a/src/player/playlist.rs b/src/player/playlist.rs index b9ea1b8..825be01 100644 --- a/src/player/playlist.rs +++ b/src/player/playlist.rs @@ -4,6 +4,7 @@ use crate::ssonic::response::Song; pub struct Playlist { song_list: VecDeque, + pub fetch_queued: bool, } impl Playlist { @@ -17,11 +18,13 @@ impl Playlist { pub fn append(&mut self, list: Vec) { self.song_list.append(VecDeque::from(list).borrow_mut()); + self.fetch_queued = false; } pub fn new() -> Playlist { Playlist { song_list: VecDeque::new(), + fetch_queued: true, // handle initial fetch outside this struct } } }