note: add copy note json

very handy
This commit is contained in:
William Casarin
2024-12-11 16:12:25 -08:00
parent a429ff689c
commit aa14fb092d

View File

@@ -2,6 +2,7 @@ use crate::colors;
use egui::{Rect, Vec2};
use enostr::{NoteId, Pubkey};
use nostrdb::{Note, NoteKey};
use tracing::error;
#[derive(Clone)]
#[allow(clippy::enum_variant_names)]
@@ -9,6 +10,7 @@ pub enum NoteContextSelection {
CopyText,
CopyPubkey,
CopyNoteId,
CopyNoteJSON,
}
impl NoteContextSelection {
@@ -33,6 +35,12 @@ impl NoteContextSelection {
}
});
}
NoteContextSelection::CopyNoteJSON => {
ui.output_mut(|w| match note.json() {
Ok(json) => w.copied_text = json,
Err(err) => error!("error copying note json: {err}"),
});
}
}
}
}
@@ -162,6 +170,10 @@ impl NoteContextButton {
context_selection = Some(NoteContextSelection::CopyNoteId);
ui.close_menu();
}
if ui.button("Copy note json").clicked() {
context_selection = Some(NoteContextSelection::CopyNoteJSON);
ui.close_menu();
}
});
context_selection