Factored out thread spawning db update.
This commit is contained in:
parent
0e8ea41ca7
commit
e03aa9dd74
@ -27,6 +27,11 @@ use gtk::prelude::*;
|
|||||||
use gio::ApplicationExt;
|
use gio::ApplicationExt;
|
||||||
use gdk_pixbuf::Pixbuf;
|
use gdk_pixbuf::Pixbuf;
|
||||||
|
|
||||||
|
/*
|
||||||
|
THIS IS STILL A PROTOTYPE.
|
||||||
|
THE CODE IS TERIBLE, SPAGHETTI AND HAS UNWRAPS EVERYWHERE.
|
||||||
|
*/
|
||||||
|
|
||||||
fn create_flowbox_child(title: &str, cover: Option<Pixbuf>) -> gtk::FlowBoxChild {
|
fn create_flowbox_child(title: &str, cover: Option<Pixbuf>) -> gtk::FlowBoxChild {
|
||||||
let build_src = include_str!("../gtk/pd_fb_child.ui");
|
let build_src = include_str!("../gtk/pd_fb_child.ui");
|
||||||
let builder = gtk::Builder::new_from_string(build_src);
|
let builder = gtk::Builder::new_from_string(build_src);
|
||||||
@ -193,6 +198,13 @@ fn episodes_listbox(connection: Arc<Mutex<SqliteConnection>>, pd_title: &str) ->
|
|||||||
list
|
list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn refresh_db(db: Arc<Mutex<SqliteConnection>>) {
|
||||||
|
let db_clone = db.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
hammond_data::index_feed::index_loop(db_clone.clone(), false).unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// I am sorry about the spaghetti code.
|
// I am sorry about the spaghetti code.
|
||||||
// Gonna clean it up when the GUI is a bit usuable.
|
// Gonna clean it up when the GUI is a bit usuable.
|
||||||
fn build_ui() {
|
fn build_ui() {
|
||||||
@ -246,8 +258,7 @@ fn build_ui() {
|
|||||||
println!("{:?} feed added", url);
|
println!("{:?} feed added", url);
|
||||||
|
|
||||||
// update the db
|
// update the db
|
||||||
// TODO: refactor the update and spin a thread.
|
refresh_db(db_clone.clone());
|
||||||
index_feed::index_loop(db_clone.clone(), false).unwrap();
|
|
||||||
|
|
||||||
// TODO: lock the button instead of hiding and add notification of feed added.
|
// TODO: lock the button instead of hiding and add notification of feed added.
|
||||||
add_popover_clone.hide();
|
add_popover_clone.hide();
|
||||||
@ -269,10 +280,7 @@ fn build_ui() {
|
|||||||
let db_clone = db.clone();
|
let db_clone = db.clone();
|
||||||
refresh_button.connect_clicked(move |_| {
|
refresh_button.connect_clicked(move |_| {
|
||||||
// fsdaa, The things I do for the borrow checker.
|
// fsdaa, The things I do for the borrow checker.
|
||||||
let db_clone = db_clone.clone();
|
refresh_db(db_clone.clone());
|
||||||
thread::spawn(move || {
|
|
||||||
hammond_data::index_feed::index_loop(db_clone.clone(), false).unwrap();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let tempdb = db.lock().unwrap();
|
let tempdb = db.lock().unwrap();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user