utils: Refactor refresh_feed
Move channel creation inside the thread. Drop the Result return type as its not needed anymore.
This commit is contained in:
parent
cc1a5783fd
commit
cd937c4844
@ -201,21 +201,18 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
refresh_feed(source, sender)
|
refresh_feed(source, sender)
|
||||||
.map_err(|err| error!("Failed to update feeds: {}", err))
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update the rss feed(s) originating from `source`.
|
/// Update the rss feed(s) originating from `source`.
|
||||||
/// If `source` is None, Fetches all the `Source` entries in the database and updates them.
|
/// If `source` is None, Fetches all the `Source` entries in the database and updates them.
|
||||||
/// When It's done,it queues up a `RefreshViews` action.
|
fn refresh_feed<S>(source: Option<S>, sender: Sender<Action>)
|
||||||
fn refresh_feed<S>(source: Option<S>, sender: Sender<Action>) -> Result<(), Error>
|
|
||||||
where
|
where
|
||||||
S: IntoIterator<Item = Source> + Send + 'static,
|
S: IntoIterator<Item = Source> + Send + 'static,
|
||||||
{
|
{
|
||||||
let (up_sender, up_receiver) = bounded(1);
|
|
||||||
sender.send(Action::ShowUpdateNotif(up_receiver));
|
|
||||||
|
|
||||||
rayon::spawn(move || {
|
rayon::spawn(move || {
|
||||||
|
let (up_sender, up_receiver) = bounded(1);
|
||||||
|
sender.send(Action::ShowUpdateNotif(up_receiver));
|
||||||
|
|
||||||
if let Some(s) = source {
|
if let Some(s) = source {
|
||||||
// Refresh only specified feeds
|
// Refresh only specified feeds
|
||||||
pipeline::run(s)
|
pipeline::run(s)
|
||||||
@ -233,7 +230,6 @@ where
|
|||||||
|
|
||||||
up_sender.send(true);
|
up_sender.send(true);
|
||||||
});
|
});
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user