From b7366351b60d0e47a2a5653db7c2a7d12cc4ef47 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 1 Jul 2024 06:46:02 -0700 Subject: [PATCH] drafts: clear post after posting Signed-off-by: William Casarin --- src/draft.rs | 6 ++++++ src/timeline.rs | 1 + 2 files changed, 7 insertions(+) diff --git a/src/draft.rs b/src/draft.rs index 8ba7ef9..f8b63a0 100644 --- a/src/draft.rs +++ b/src/draft.rs @@ -11,6 +11,12 @@ pub struct Drafts { pub compose: Draft, } +impl Drafts { + pub fn clear(&mut self, source: DraftSource) { + source.draft(self).buffer = "".to_string(); + } +} + pub enum DraftSource<'a> { Compose, Reply(&'a [u8; 32]), // note id diff --git a/src/timeline.rs b/src/timeline.rs index 8416911..0005e12 100644 --- a/src/timeline.rs +++ b/src/timeline.rs @@ -296,6 +296,7 @@ pub fn timeline_view(ui: &mut egui::Ui, app: &mut Damus, timeline: usize) { let raw_msg = format!("[\"EVENT\",{}]", note.json().unwrap()); info!("sending {}", raw_msg); app.pool.send(&enostr::ClientMessage::raw(raw_msg)); + app.drafts.clear(DraftSource::Compose); } } }