diff options
Diffstat (limited to 'src/app/update.rs')
-rw-r--r-- | src/app/update.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/app/update.rs b/src/app/update.rs index f1576b5..baf4651 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -17,6 +17,7 @@ pub enum Msg { ShowUpdateForm { event: Event }, AddEvent { new: Event }, UpdateEvent { old: Event, new: Event }, + DeleteEvent { event: Event }, } pub async fn event_handler(rx: Receiver<Msg>, mut app: App) { @@ -47,6 +48,15 @@ pub async fn event_handler(rx: Receiver<Msg>, mut app: App) { None => println!("Event not found when updating from {:?} to {:?}", old, new), } } + Msg::DeleteEvent { event } => { + match app.events.iter().position(|e| e.id == event.id) { + Some(index) => { + app.events.remove(index); + calendar::refresh_date(&app, event.date); + } + None => println!("Event not found when trying to delete {:?}", event), + } + } } } } |