Handle playlist fetching signalling better

This commit is contained in:
Muaz Ahmad 2024-12-13 12:37:44 +05:00
parent 9c4914178d
commit 1b37071836
2 changed files with 4 additions and 1 deletions

View file

@ -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(())

View file

@ -4,6 +4,7 @@ use crate::ssonic::response::Song;
pub struct Playlist {
song_list: VecDeque<Song>,
pub fetch_queued: bool,
}
impl Playlist {
@ -17,11 +18,13 @@ impl Playlist {
pub fn append(&mut self, list: Vec<Song>) {
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
}
}
}