diff options
author | Joris | 2022-02-26 18:35:24 +0100 |
---|---|---|
committer | Joris | 2022-02-26 18:35:24 +0100 |
commit | 2d80413609130f1c121dcae39a150a27dd9f02ea (patch) | |
tree | a8c807b7e95d5049ea43a1757d292b5cb745524b /src/app/app.rs | |
parent | 1445e23a26c6581ad0c3f5b5016e47e95d224e9f (diff) |
Show repeated events
Diffstat (limited to 'src/app/app.rs')
-rw-r--r-- | src/app/app.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/app/app.rs b/src/app/app.rs index b1ee395..58240af 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -1,7 +1,7 @@ use gtk4 as gtk; use async_channel::Sender; -use chrono::{Datelike, NaiveDate, Weekday}; +use chrono::{Datelike, Duration, NaiveDate, Weekday}; use gtk::glib::signal::Inhibit; use gtk::prelude::*; use rusqlite::Connection; @@ -16,8 +16,10 @@ pub struct App { pub window: Rc<gtk::ApplicationWindow>, pub grid: gtk::Grid, pub events: Vec<Event>, + pub repeated_events: Vec<Event>, pub today: NaiveDate, pub start_date: NaiveDate, + pub end_date: NaiveDate, pub tx: Sender<Msg>, } @@ -36,8 +38,19 @@ impl App { let today = chrono::offset::Local::today().naive_utc(); let start_date = NaiveDate::from_isoywd(today.year(), today.iso_week().week(), Weekday::Mon); - let events = db::list(&conn).unwrap_or(vec![]); - let grid = calendar::create(tx.clone(), &today, &start_date, &events); + let end_date = start_date + Duration::days(7 * 4 - 1); + + let events = db::list_non_repeated_between(&conn, start_date, end_date).unwrap_or(vec![]); + let repeated_events = db::list_repeated(&conn).unwrap_or(vec![]); + + let grid = calendar::create( + tx.clone(), + today, + start_date, + end_date, + &events, + &repeated_events, + ); window.set_child(Some(&grid)); @@ -53,8 +66,10 @@ impl App { window, grid, events, + repeated_events, today, start_date, + end_date, tx, } } |