commit 61deeb03e1aa15ebe3198033b135acea37e80d8c
parent 32923abfc21e8f82f5eca0c46b5f6ceee72e7b6b
Author: William Casarin <jb55@jb55.com>
Date: Wed, 24 Apr 2024 08:53:21 -0700
note: support nprofile mentions
realized we were missing this bit
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 28 insertions(+), 23 deletions(-)
diff --git a/src/ui/note/contents.rs b/src/ui/note/contents.rs
@@ -97,6 +97,29 @@ fn render_note_preview(
.response
}
+fn mention_ui(app: &mut Damus, txn: &Transaction, pk: &[u8; 32], ui: &mut egui::Ui) {
+ #[cfg(feature = "profiling")]
+ puffin::profile_function!();
+
+ let profile = app.ndb.get_profile_by_pubkey(txn, pk).ok();
+
+ let name: String =
+ if let Some(name) = profile.as_ref().and_then(crate::profile::get_profile_name) {
+ format!("@{}", name.username())
+ } else {
+ "??".to_string()
+ };
+
+ let resp = ui.colored_label(colors::PURPLE, &name);
+
+ if let Some(rec) = profile.as_ref() {
+ resp.on_hover_ui_at_pointer(|ui| {
+ ui.set_max_width(300.0);
+ ui.add(ui::ProfilePreview::new(rec, &mut app.img_cache));
+ });
+ }
+}
+
fn render_note_contents(
ui: &mut egui::Ui,
damus: &mut Damus,
@@ -125,30 +148,12 @@ fn render_note_contents(
for block in blocks.iter(note) {
match block.blocktype() {
BlockType::MentionBech32 => match block.as_mention().unwrap() {
+ Mention::Profile(profile) => {
+ mention_ui(damus, txn, profile.pubkey(), ui);
+ }
+
Mention::Pubkey(npub) => {
- #[cfg(feature = "profiling")]
- puffin::profile_scope!("pubkey contents");
-
- ui.horizontal(|ui| {
- let profile = damus.ndb.get_profile_by_pubkey(txn, npub.pubkey()).ok();
-
- let name: String = if let Some(name) =
- profile.as_ref().and_then(crate::profile::get_profile_name)
- {
- format!("@{}", name.username())
- } else {
- "??".to_string()
- };
-
- let resp = ui.colored_label(colors::PURPLE, &name);
-
- if let Some(rec) = profile.as_ref() {
- resp.on_hover_ui_at_pointer(|ui| {
- ui.set_max_width(300.0);
- ui.add(ui::ProfilePreview::new(rec, &mut damus.img_cache));
- });
- }
- });
+ mention_ui(damus, txn, npub.pubkey(), ui);
}
Mention::Note(note) if options.has_note_previews() => {