Handle playlist fetching signalling better
This commit is contained in:
parent
9c4914178d
commit
1b37071836
2 changed files with 4 additions and 1 deletions
|
@ -55,7 +55,7 @@ impl Player {
|
||||||
PlayerEvent::FFTBins(bins) => self.tui_root.metadata.update_spectrogram(bins),
|
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)?;
|
self.api_chan.send(APIEvent::FetchRandom)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -4,6 +4,7 @@ use crate::ssonic::response::Song;
|
||||||
|
|
||||||
pub struct Playlist {
|
pub struct Playlist {
|
||||||
song_list: VecDeque<Song>,
|
song_list: VecDeque<Song>,
|
||||||
|
pub fetch_queued: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Playlist {
|
impl Playlist {
|
||||||
|
@ -17,11 +18,13 @@ impl Playlist {
|
||||||
|
|
||||||
pub fn append(&mut self, list: Vec<Song>) {
|
pub fn append(&mut self, list: Vec<Song>) {
|
||||||
self.song_list.append(VecDeque::from(list).borrow_mut());
|
self.song_list.append(VecDeque::from(list).borrow_mut());
|
||||||
|
self.fetch_queued = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new() -> Playlist {
|
pub fn new() -> Playlist {
|
||||||
Playlist {
|
Playlist {
|
||||||
song_list: VecDeque::new(),
|
song_list: VecDeque::new(),
|
||||||
|
fetch_queued: true, // handle initial fetch outside this struct
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue