Skip to content

Commit

Permalink
Fix 'annotate' state of draft
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedilger committed Jul 27, 2024
1 parent 2b3761b commit 3332d14
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 1 addition & 3 deletions gossip-bin/src/ui/feed/note/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@ pub fn render_note_inner(
if let Some(channel) =
DmChannel::from_event(&note.event, None)
{
app.draft_is_annotate = false;
app.draft_needs_focus = true;
app.show_post_area = true;

Expand All @@ -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;

Expand Down Expand Up @@ -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)
}),
)));
Expand Down
8 changes: 4 additions & 4 deletions gossip-bin/src/ui/feed/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
});

Expand Down Expand Up @@ -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:"
Expand Down Expand Up @@ -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,
});
}
Expand All @@ -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,
});
}
Expand Down
8 changes: 6 additions & 2 deletions gossip-bin/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ pub struct DraftData {
pub tagging_search_selected: Option<usize>,
pub tagging_search_searched: Option<String>,
pub tagging_search_results: Vec<(String, PublicKey)>,

// If this is an annotation
pub is_annotate: bool,
}

impl Default for DraftData {
Expand All @@ -360,6 +363,8 @@ impl Default for DraftData {
tagging_search_selected: None,
tagging_search_searched: None,
tagging_search_results: Vec::new(),

is_annotate: false,
}
}
}
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 3332d14

Please sign in to comment.