From 3a68d8fd002174c7dafdb7e97375c07e66e59f32 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Mon, 9 Jan 2023 21:14:26 +1300 Subject: [PATCH] Add reply 'p' tags before user presses Send, so they can see who is tagged: I will fix it so it renders their name. Eventually I'll make it so you can delete people so they don't get tagged on the reply. --- src/overlord/mod.rs | 5 +++++ src/ui/feed.rs | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/overlord/mod.rs b/src/overlord/mod.rs index f35ef1d6..5df39275 100644 --- a/src/overlord/mod.rs +++ b/src/overlord/mod.rs @@ -695,6 +695,7 @@ impl Overlord { }; // Get the event we are replying to + /* let event = match GLOBALS.events.get(&reply_to) { Some(e) => e, None => { @@ -703,6 +704,7 @@ impl Overlord { )) } }; + */ // Add an 'e' tag for the note we are replying to tags.push(Tag::Event { @@ -711,6 +713,8 @@ impl Overlord { marker: Some("reply".to_string()), }); + /* These are now done in the UI so the poster can refer to them + // Add a 'p' tag for the author we are replying to tags.push(Tag::Pubkey { pubkey: event.pubkey, @@ -731,6 +735,7 @@ impl Overlord { tags.extend(parent_p_tags); // FIXME deduplicate 'p' tags + */ if GLOBALS.settings.read().await.set_client_tag { tags.push(Tag::Other { diff --git a/src/ui/feed.rs b/src/ui/feed.rs index 79b7018a..0e4e8f41 100644 --- a/src/ui/feed.rs +++ b/src/ui/feed.rs @@ -540,6 +540,25 @@ fn render_post_actual( if ui.add(ReplyButton {}).clicked() { app.replying_to = Some(event.id); + + // Add a 'p' tag for the author we are replying to + app.draft_tags.push(Tag::Pubkey { + pubkey: event.pubkey, + recommended_relay_url: None, // FIXME + petname: None, + }); + + // Add all the 'p' tags from the note we are replying to + let parent_p_tags: Vec = event + .tags + .iter() + .filter(|t| match t { + Tag::Pubkey { pubkey, .. } => *pubkey != event.pubkey, + _ => false, + }) + .map(|t| t.to_owned()) + .collect(); + app.draft_tags.extend(parent_p_tags); } ui.add_space(24.0);