Now Upon feed addition only that feed is indexed/updated.
This commit is contained in:
@@ -36,15 +36,14 @@ pub fn get_headerbar(db: Arc<Mutex<SqliteConnection>>, stack: gtk::Stack) -> gtk
|
||||
let f = index_feed::insert_return_source(&tempdb, &url);
|
||||
drop(tempdb);
|
||||
info!("{:?} feed added", url);
|
||||
if f.is_err() {
|
||||
if let Ok(mut source) = f {
|
||||
// update the db
|
||||
utils::refresh_feed(db_clone.clone(), stack_clone.clone(), &mut source);
|
||||
} else {
|
||||
error!("Expected Error, feed probably already exists.");
|
||||
error!("Error: {:?}", f.unwrap_err());
|
||||
}
|
||||
|
||||
// update the db
|
||||
// TODO: have it fettch only the added feed.
|
||||
utils::refresh_db(db_clone.clone(), stack_clone.clone());
|
||||
|
||||
// TODO: lock the button instead of hiding and add notification of feed added.
|
||||
// TODO: map the spinner
|
||||
add_popover_clone.hide();
|
||||
|
||||
@@ -54,6 +54,8 @@ fn build_ui(app: >k::Application) {
|
||||
|
||||
// Get the headerbar
|
||||
let header = headerbar::get_headerbar(db.clone(), stack.clone());
|
||||
// Uncomment this when etag implementation is fixed and refesh_db thread is non blocking.
|
||||
// utils::refresh_db(db.clone(), stack.clone());
|
||||
window.set_titlebar(&header);
|
||||
|
||||
window.show_all();
|
||||
|
||||
@@ -4,6 +4,7 @@ use gtk;
|
||||
// use gtk::prelude::*;
|
||||
|
||||
use hammond_data;
|
||||
use hammond_data::models::Source;
|
||||
use diesel::prelude::SqliteConnection;
|
||||
|
||||
use std::thread;
|
||||
@@ -25,8 +26,34 @@ pub fn refresh_db(db: Arc<Mutex<SqliteConnection>>, stack: gtk::Stack) {
|
||||
handle.join();
|
||||
|
||||
podcasts_view::update_podcasts_view(db.clone(), stack.clone());
|
||||
// let foo = stack.emit("foo", &[]);
|
||||
// info!("{:?}", foo)
|
||||
}
|
||||
|
||||
pub fn refresh_feed(db: Arc<Mutex<SqliteConnection>>, stack: gtk::Stack, source: &mut Source) {
|
||||
let db_clone = db.clone();
|
||||
let source_ = source.clone();
|
||||
// TODO: add timeout option and error reporting.
|
||||
let handle = thread::spawn(move || {
|
||||
let db_ = db_clone.lock().unwrap();
|
||||
let foo = hammond_data::index_feed::refresh_source(&db_, &mut source_.clone(), false);
|
||||
drop(db_);
|
||||
|
||||
if let Ok((mut req, s)) = foo {
|
||||
let s = hammond_data::index_feed::complete_index_from_source(
|
||||
&mut req,
|
||||
&s,
|
||||
db_clone.clone(),
|
||||
);
|
||||
if s.is_err() {
|
||||
error!("Error While trying to update the database.");
|
||||
error!("Error msg: {}", s.unwrap_err());
|
||||
};
|
||||
};
|
||||
});
|
||||
// FIXME: atm freezing the ui till update is done.
|
||||
// Make it instead emmit a signal on update completion.
|
||||
handle.join();
|
||||
|
||||
podcasts_view::update_podcasts_view(db.clone(), stack.clone());
|
||||
}
|
||||
|
||||
// https://github.
|
||||
|
||||
Reference in New Issue
Block a user