Thats a hack, a terrible one, but without it the user

would have to manually click refresh if the user that was added
happen to redirect somewhere else.

The problem is in the hammond-data/src/models/source.rs
fn request_constructor. It has to do with futures and lifetimes
and I am not sure how to tackle it yet.
This commit is contained in:
Jordan Petridis
2018-02-03 00:06:02 +02:00
parent f1f248fa40
commit e8ae0b0251
3 changed files with 56 additions and 4 deletions
+28 -4
View File
@@ -23,11 +23,35 @@ pub fn refresh_feed(source: Option<Vec<Source>>, sender: Sender<Action>) {
sender.send(Action::HeaderBarShowUpdateIndicator).unwrap();
thread::spawn(move || {
let sources = source.unwrap_or_else(|| dbqueries::get_sources().unwrap());
let mut sources = source.unwrap_or_else(|| dbqueries::get_sources().unwrap());
if let Err(err) = pipeline::run(sources, false) {
error!("Error While trying to update the database.");
error!("Error msg: {}", err);
// Work around to improve the feed addition experience.
// Many times links to rss feeds are just redirects(usually to an https version).
// Sadly I haven't figured yet a nice way to follow up links redirects without getting
// to lifetime hell with futures and hyper.
// So the requested refresh is only of 1 feed, and the feed fails to be indexed,
// (as a 301 redict would update the source entry and exit), another refresh is run.
// For more see hammond_data/src/models/source.rs `fn request_constructor`.
// also ping me on irc if or open an issue if you want to tackle it.
if sources.len() == 1 {
let source = sources.remove(0);
let id = source.id();
if let Err(err) = pipeline::index_single_source(source, false) {
error!("Error While trying to update the database.");
error!("Error msg: {}", err);
let source = dbqueries::get_source_from_id(id).unwrap();
if let Err(err) = pipeline::index_single_source(source, false) {
error!("Error While trying to update the database.");
error!("Error msg: {}", err);
}
}
} else {
// This is what would normally run
if let Err(err) = pipeline::run(sources, false) {
error!("Error While trying to update the database.");
error!("Error msg: {}", err);
}
}
sender.send(Action::HeaderBarHideUpdateIndicator).unwrap();