diff --git a/TODO.md b/TODO.md
index c6f9265..50224ee 100644
--- a/TODO.md
+++ b/TODO.md
@@ -18,6 +18,7 @@
- [ ] Headerbar back button and stack switching
- [x] New episode notifier on podcast_flowbox_child, like the one vocal has
- [ ] Polish the flowbox_child banner.
+- [x] Update on startup
**Unhack stuff:**
@@ -50,7 +51,7 @@
- [ ] Discuss and decide when to schedule the download cleaner. [#3](https://gitlab.gnome.org/alatiera/Hammond/issues/3)
- [ ] Unplayed Only and Downloaded only view.
-- [ ] Auto-updater, update on startup
+- [ ] Auto-updater
- [ ] Make use of file metadas, [This](https://github.com/GuillaumeGomez/audio-video-metadata) might be helpfull.
- [ ] OPML import/export // Probably need to create a crate.
diff --git a/hammond-gtk/src/headerbar.rs b/hammond-gtk/src/headerbar.rs
index 7ac1d69..3ec1930 100644
--- a/hammond-gtk/src/headerbar.rs
+++ b/hammond-gtk/src/headerbar.rs
@@ -49,7 +49,7 @@ pub fn get_headerbar(db: &Database, stack: >k::Stack) -> gtk::HeaderBar {
// FIXME: There appears to be a memmory leak here.
refresh_button.connect_clicked(clone!(stack, db => move |_| {
- utils::refresh_feed(&db, &stack, None);
+ utils::refresh_feed(&db, &stack, None, None);
}));
header
@@ -64,7 +64,7 @@ fn on_add_bttn_clicked(db: &Database, stack: >k::Stack, url: &str) {
if let Ok(s) = source {
// update the db
- utils::refresh_feed(db, stack, Some(vec![s]));
+ utils::refresh_feed(db, stack, Some(vec![s]), None);
} else {
error!("Expected Error, feed probably already exists.");
error!("Error: {:?}", source.unwrap_err());
diff --git a/hammond-gtk/src/main.rs b/hammond-gtk/src/main.rs
index a12acb0..f21b854 100644
--- a/hammond-gtk/src/main.rs
+++ b/hammond-gtk/src/main.rs
@@ -89,6 +89,12 @@ fn build_ui(app: >k::Application) {
}));
app.add_action(&check);
+ // queue a db update 1 minute after the startup.
+ gtk::idle_add(clone!(db, stack => move || {
+ utils::refresh_feed(&db, &stack, None, Some(60));
+ glib::Continue(false)
+ }));
+
// Get the headerbar
let header = headerbar::get_headerbar(&db, &stack);
diff --git a/hammond-gtk/src/utils.rs b/hammond-gtk/src/utils.rs
index d3631fb..c06f505 100644
--- a/hammond-gtk/src/utils.rs
+++ b/hammond-gtk/src/utils.rs
@@ -5,22 +5,27 @@ use hammond_data::index_feed;
use hammond_data::models::Source;
use hammond_data::index_feed::Database;
-use std::thread;
+use std::{thread, time};
use std::cell::RefCell;
use std::sync::mpsc::{channel, Receiver};
use views::podcasts_view;
+type Foo = RefCell