From 3332d146205c5330596d03a9bf205a55e167dceb Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Sat, 27 Jul 2024 12:08:49 +1200 Subject: [PATCH] Fix 'annotate' state of draft --- gossip-bin/src/ui/feed/note/mod.rs | 4 +--- gossip-bin/src/ui/feed/post.rs | 8 ++++---- gossip-bin/src/ui/mod.rs | 8 ++++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/gossip-bin/src/ui/feed/note/mod.rs b/gossip-bin/src/ui/feed/note/mod.rs index 145f1148..e6da2ae9 100644 --- a/gossip-bin/src/ui/feed/note/mod.rs +++ b/gossip-bin/src/ui/feed/note/mod.rs @@ -746,7 +746,6 @@ pub fn render_note_inner( if let Some(channel) = DmChannel::from_event(¬e.event, None) { - app.draft_is_annotate = false; app.draft_needs_focus = true; app.show_post_area = true; @@ -766,7 +765,6 @@ pub fn render_note_inner( .on_hover_text("Reply") .clicked() { - app.draft_is_annotate = false; app.draft_needs_focus = true; app.show_post_area = true; @@ -1381,10 +1379,10 @@ fn note_actions( my_items.push(MoreMenuItem::Button(MoreMenuButton::new( "Annotate", Box::new(|_ui, app| { - app.draft_is_annotate = true; app.draft_needs_focus = true; app.show_post_area = true; + app.draft_data.is_annotate = true; app.draft_data.replying_to = Some(note.event.id) }), ))); diff --git a/gossip-bin/src/ui/feed/post.rs b/gossip-bin/src/ui/feed/post.rs index 2126d27f..3961fafa 100644 --- a/gossip-bin/src/ui/feed/post.rs +++ b/gossip-bin/src/ui/feed/post.rs @@ -369,7 +369,7 @@ fn dm_posting_area( content: app.dm_draft_data.draft.clone(), tags, in_reply_to: None, - annotation: app.draft_is_annotate, + annotation: app.dm_draft_data.is_annotate, dm_channel: Some(dm_channel.to_owned()), }); @@ -414,7 +414,7 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, ui: &mut Ui) { .max_height(window_height * 0.7) .show(ui, |ui| { if let Some(id) = app.draft_data.replying_to.or(app.draft_data.repost) { - let msg = if app.draft_is_annotate { + let msg = if app.draft_data.is_annotate { "Annotating:" } else { "Replying to:" @@ -720,7 +720,7 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, ui: &mut Ui) { content: replaced, tags, in_reply_to: Some(replying_to_id), - annotation: app.draft_is_annotate, + annotation: app.draft_data.is_annotate, dm_channel: None, }); } @@ -734,7 +734,7 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, ui: &mut Ui) { content: replaced, tags, in_reply_to: None, - annotation: app.draft_is_annotate, + annotation: app.draft_data.is_annotate, dm_channel: None, }); } diff --git a/gossip-bin/src/ui/mod.rs b/gossip-bin/src/ui/mod.rs index eecd95ea..6cae05b2 100644 --- a/gossip-bin/src/ui/mod.rs +++ b/gossip-bin/src/ui/mod.rs @@ -336,6 +336,9 @@ pub struct DraftData { pub tagging_search_selected: Option, pub tagging_search_searched: Option, pub tagging_search_results: Vec<(String, PublicKey)>, + + // If this is an annotation + pub is_annotate: bool, } impl Default for DraftData { @@ -360,6 +363,8 @@ impl Default for DraftData { tagging_search_selected: None, tagging_search_searched: None, tagging_search_results: Vec::new(), + + is_annotate: false, } } } @@ -382,6 +387,7 @@ impl DraftData { self.tagging_search_selected = None; self.tagging_search_searched = None; self.tagging_search_results.clear(); + self.is_annotate = false; } } @@ -469,7 +475,6 @@ struct GossipUi { unlock_needs_focus: bool, draft_data: DraftData, dm_draft_data: DraftData, - draft_is_annotate: bool, // User entry: metadata editing_metadata: bool, @@ -719,7 +724,6 @@ impl GossipUi { unlock_needs_focus: true, draft_data: DraftData::default(), dm_draft_data: DraftData::default(), - draft_is_annotate: false, editing_metadata: false, metadata: Metadata::new(), delegatee_tag_str: "".to_owned(),