diff options
author | Joris | 2022-03-12 13:27:29 +0100 |
---|---|---|
committer | Joris | 2022-03-12 13:36:09 +0100 |
commit | d584df359640176ec4bc06f59d1e8d42ab17a413 (patch) | |
tree | 6cfaf676fc2ecf4e61067aa376fb2bed0d984d79 /src/gui/app.rs | |
parent | aad7b9601dfa05255d5c24f4a6377d9a25646d45 (diff) |
Update and delete recurring events
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, - } + }) } } |