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