Fix 'annotate' state of draft

This commit is contained in:
Mike Dilger 2024-07-27 12:08:49 +12:00
parent 2b3761b233
commit 3332d14620
3 changed files with 11 additions and 9 deletions

View File

@ -746,7 +746,6 @@ pub fn render_note_inner(
if let Some(channel) = if let Some(channel) =
DmChannel::from_event(&note.event, None) DmChannel::from_event(&note.event, None)
{ {
app.draft_is_annotate = false;
app.draft_needs_focus = true; app.draft_needs_focus = true;
app.show_post_area = true; app.show_post_area = true;
@ -766,7 +765,6 @@ pub fn render_note_inner(
.on_hover_text("Reply") .on_hover_text("Reply")
.clicked() .clicked()
{ {
app.draft_is_annotate = false;
app.draft_needs_focus = true; app.draft_needs_focus = true;
app.show_post_area = true; app.show_post_area = true;
@ -1381,10 +1379,10 @@ fn note_actions(
my_items.push(MoreMenuItem::Button(MoreMenuButton::new( my_items.push(MoreMenuItem::Button(MoreMenuButton::new(
"Annotate", "Annotate",
Box::new(|_ui, app| { Box::new(|_ui, app| {
app.draft_is_annotate = true;
app.draft_needs_focus = true; app.draft_needs_focus = true;
app.show_post_area = true; app.show_post_area = true;
app.draft_data.is_annotate = true;
app.draft_data.replying_to = Some(note.event.id) app.draft_data.replying_to = Some(note.event.id)
}), }),
))); )));

View File

@ -369,7 +369,7 @@ fn dm_posting_area(
content: app.dm_draft_data.draft.clone(), content: app.dm_draft_data.draft.clone(),
tags, tags,
in_reply_to: None, in_reply_to: None,
annotation: app.draft_is_annotate, annotation: app.dm_draft_data.is_annotate,
dm_channel: Some(dm_channel.to_owned()), 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) .max_height(window_height * 0.7)
.show(ui, |ui| { .show(ui, |ui| {
if let Some(id) = app.draft_data.replying_to.or(app.draft_data.repost) { 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:" "Annotating:"
} else { } else {
"Replying to:" "Replying to:"
@ -720,7 +720,7 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, ui: &mut Ui) {
content: replaced, content: replaced,
tags, tags,
in_reply_to: Some(replying_to_id), in_reply_to: Some(replying_to_id),
annotation: app.draft_is_annotate, annotation: app.draft_data.is_annotate,
dm_channel: None, dm_channel: None,
}); });
} }
@ -734,7 +734,7 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, ui: &mut Ui) {
content: replaced, content: replaced,
tags, tags,
in_reply_to: None, in_reply_to: None,
annotation: app.draft_is_annotate, annotation: app.draft_data.is_annotate,
dm_channel: None, dm_channel: None,
}); });
} }

View File

@ -336,6 +336,9 @@ pub struct DraftData {
pub tagging_search_selected: Option<usize>, pub tagging_search_selected: Option<usize>,
pub tagging_search_searched: Option<String>, pub tagging_search_searched: Option<String>,
pub tagging_search_results: Vec<(String, PublicKey)>, pub tagging_search_results: Vec<(String, PublicKey)>,
// If this is an annotation
pub is_annotate: bool,
} }
impl Default for DraftData { impl Default for DraftData {
@ -360,6 +363,8 @@ impl Default for DraftData {
tagging_search_selected: None, tagging_search_selected: None,
tagging_search_searched: None, tagging_search_searched: None,
tagging_search_results: Vec::new(), tagging_search_results: Vec::new(),
is_annotate: false,
} }
} }
} }
@ -382,6 +387,7 @@ impl DraftData {
self.tagging_search_selected = None; self.tagging_search_selected = None;
self.tagging_search_searched = None; self.tagging_search_searched = None;
self.tagging_search_results.clear(); self.tagging_search_results.clear();
self.is_annotate = false;
} }
} }
@ -469,7 +475,6 @@ struct GossipUi {
unlock_needs_focus: bool, unlock_needs_focus: bool,
draft_data: DraftData, draft_data: DraftData,
dm_draft_data: DraftData, dm_draft_data: DraftData,
draft_is_annotate: bool,
// User entry: metadata // User entry: metadata
editing_metadata: bool, editing_metadata: bool,
@ -719,7 +724,6 @@ impl GossipUi {
unlock_needs_focus: true, unlock_needs_focus: true,
draft_data: DraftData::default(), draft_data: DraftData::default(),
dm_draft_data: DraftData::default(), dm_draft_data: DraftData::default(),
draft_is_annotate: false,
editing_metadata: false, editing_metadata: false,
metadata: Metadata::new(), metadata: Metadata::new(),
delegatee_tag_str: "".to_owned(), delegatee_tag_str: "".to_owned(),