EpisodesListBox: Do not block while fetching episode backlog.
This commit is contained in:
parent
701b759ba2
commit
cc84a4637d
@ -352,7 +352,7 @@ fn total_size_helper(
|
||||
// }
|
||||
|
||||
pub fn episodes_listbox(pd: Arc<Podcast>, sender: Sender<Action>) -> Result<gtk::ListBox, Error> {
|
||||
// use crossbeam_channel::TryRecvError::*;
|
||||
use crossbeam_channel::TryRecvError::*;
|
||||
use crossbeam_channel::bounded;
|
||||
|
||||
let count = dbqueries::get_pd_episodes_count(&pd)?;
|
||||
@ -376,14 +376,15 @@ pub fn episodes_listbox(pd: Arc<Podcast>, sender: Sender<Action>) -> Result<gtk:
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
let episodes = receiver.recv().unwrap();
|
||||
// Ok(e) => e,
|
||||
// Err(Empty) => return glib::Continue(true),
|
||||
// Err(Disconnected) => return glib::Continue(false),
|
||||
// };
|
||||
gtk::idle_add(clone!(list => move || {
|
||||
let episodes = match receiver.try_recv() {
|
||||
Ok(e) => e,
|
||||
Err(Empty) => return glib::Continue(true),
|
||||
Err(Disconnected) => return glib::Continue(false),
|
||||
};
|
||||
|
||||
let mut idx = 0;
|
||||
gtk::idle_add(clone!(list => move || {
|
||||
gtk::idle_add(clone!(list, sender => move || {
|
||||
if idx >= episodes.len() { return glib::Continue(false) }
|
||||
|
||||
episodes.get(idx).cloned().map(|ep| {
|
||||
@ -395,5 +396,8 @@ pub fn episodes_listbox(pd: Arc<Podcast>, sender: Sender<Action>) -> Result<gtk:
|
||||
glib::Continue(true)
|
||||
}));
|
||||
|
||||
glib::Continue(false)
|
||||
}));
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user