diff options
author | Joris | 2022-01-09 13:39:10 +0100 |
---|---|---|
committer | Joris | 2022-01-09 13:39:10 +0100 |
commit | 5166efe517291f5c9fc6326f30651ef799d6db65 (patch) | |
tree | 36df3d65c9e7218bff2264391032ecd28001a688 /src/app/update.rs | |
parent | 99af88a840bef534540a4b273d24a8a17e7fc9b9 (diff) |
Add id in event model
Diffstat (limited to 'src/app/update.rs')
-rw-r--r-- | src/app/update.rs | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/src/app/update.rs b/src/app/update.rs index 288ec51..e7bf7af 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -1,16 +1,12 @@ -use gtk4 as gtk; - use async_channel::{Receiver, Sender}; use chrono::NaiveDate; -use gtk::prelude::*; use rusqlite::Connection; use std::rc::Rc; -use crate::app::calendar; -use crate::app::form; -use crate::app::utils; -use crate::app::App; -use crate::model::event::Event; +use crate::{ + app::{calendar, form, utils, App}, + model::event::Event, +}; pub fn send(tx: Sender<Msg>, msg: Msg) { utils::spawn(async move { @@ -27,25 +23,12 @@ pub async fn event_handler(conn: Rc<Connection>, rx: Receiver<Msg>, tx: Sender<M while let Ok(msg) = rx.recv().await { match msg { Msg::ShowAddForm { date } => { - form::dialog(Rc::clone(&conn), tx.clone(), Rc::clone(&app.window), date).await; + form::show(Rc::clone(&conn), tx.clone(), Rc::clone(&app.window), date).await; } Msg::AddEvent { event } => { let date = event.date.clone(); - - let d = date.signed_duration_since(app.start_date).num_days(); - app.events.push(event); - - let col = (d % 7) as i32; - let row = 1 + (d / 7) as i32; - - app.grid.attach( - &calendar::day_entry(tx.clone(), &date, &app.today, &app.events), - col, - row, - 1, - 1, - ); + calendar::refresh_date(&app, date); } } } |