Add copy button to pubkey of post

This commit is contained in:
Mike Dilger 2022-12-28 16:20:26 +13:00
parent 8d07305875
commit d4b70fd85c
2 changed files with 9 additions and 0 deletions

View File

@ -160,6 +160,10 @@ fn render_post(
ui.label(RichText::new(GossipUi::pubkey_short(&event.pubkey)).weak());
if ui.add(CopyButton { }).clicked() {
ui.output().copied_text = GossipUi::pubkey_long(&event.pubkey);
}
ui.with_layout(Layout::right_to_left(Align::TOP), |ui| {
ui.label(
RichText::new(crate::date_ago::date_ago(event.created_at))

View File

@ -198,4 +198,9 @@ impl GossipUi {
let hex: PublicKeyHex = (*pubkey).into();
Self::hex_pubkey_short(&hex)
}
pub fn pubkey_long(pubkey: &PublicKey) -> String {
let hex: PublicKeyHex = (*pubkey).into();
hex.0
}
}