do not add unnecessary tags when mentioning people.

This commit is contained in:
fiatjaf 2023-01-13 20:15:52 -03:00 committed by Mike Dilger
parent bc88fe979c
commit 7540ee473a

View File

@ -183,13 +183,22 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
ui.menu_button("@", |ui| { ui.menu_button("@", |ui| {
for pair in pairs { for pair in pairs {
if ui.button(pair.0).clicked() { if ui.button(pair.0).clicked() {
let idx = app
.draft_tags
.iter()
.position(|tag| match tag {
Tag::Pubkey { pubkey, .. } if pubkey.0 == *pair.1 => true,
_ => false,
})
.unwrap_or_else(|| {
app.draft_tags.push(Tag::Pubkey { app.draft_tags.push(Tag::Pubkey {
pubkey: pair.1, pubkey: pair.1,
recommended_relay_url: None, // FIXME recommended_relay_url: None, // FIXME
petname: None, petname: None,
}); });
app.draft app.draft_tags.len() - 1
.push_str(&format!("#[{}]", app.draft_tags.len() - 1)); });
app.draft.push_str(&format!("#[{}]", idx));
app.tag_someone = "".to_owned(); app.tag_someone = "".to_owned();
} }
} }