diff options
Diffstat (limited to 'src/gui/app.rs')
-rw-r--r-- | src/gui/app.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/gui/app.rs b/src/gui/app.rs index ebaceb3..9f37301 100644 --- a/src/gui/app.rs +++ b/src/gui/app.rs @@ -1,5 +1,6 @@ use gtk4 as gtk; +use anyhow::Result; use async_channel::Sender; use chrono::{Datelike, Duration, NaiveDate, Weekday}; use gtk::glib::signal::Inhibit; @@ -16,7 +17,7 @@ pub struct App { pub window: Rc<gtk::ApplicationWindow>, pub grid: gtk::Grid, pub events: Vec<Event>, - pub repeated_events: Vec<Event>, + pub recurring_events: Vec<Event>, pub today: NaiveDate, pub start_date: NaiveDate, pub end_date: NaiveDate, @@ -24,7 +25,7 @@ pub struct App { } impl App { - pub fn new(conn: Rc<Connection>, app: >k::Application, tx: Sender<Msg>) -> Self { + pub fn new(conn: Rc<Connection>, app: >k::Application, tx: Sender<Msg>) -> Result<Self> { let window = Rc::new( gtk::ApplicationWindow::builder() .application(app) @@ -40,8 +41,8 @@ impl App { NaiveDate::from_isoywd(today.year(), today.iso_week().week(), Weekday::Mon); let end_date = start_date + Duration::days(7 * 4 - 1); - let events = db::list_non_repeated_between(&conn, start_date, end_date).unwrap_or_default(); - let repeated_events = db::list_repeated(&conn).unwrap_or_default(); + let events = db::list_non_recurring_between(&conn, start_date, end_date)?; + let recurring_events = db::list_recurring(&conn)?; let grid = calendar::create( tx.clone(), @@ -49,7 +50,7 @@ impl App { start_date, end_date, &events, - &repeated_events, + &recurring_events, ); window.set_child(Some(&grid)); @@ -61,16 +62,16 @@ impl App { Inhibit(false) }); - Self { + Ok(Self { conn, window, grid, events, - repeated_events, + recurring_events, today, start_date, end_date, tx, - } + }) } } |