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.
This commit is contained in:
Mike Dilger 2023-01-09 21:14:26 +13:00
parent 0654b7e70d
commit 3a68d8fd00
2 changed files with 24 additions and 0 deletions

View File

@ -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 {

View File

@ -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<Tag> = 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);