note: support nprofile mentions
realized we were missing this bit Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -97,6 +97,29 @@ fn render_note_preview(
|
|||||||
.response
|
.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(
|
fn render_note_contents(
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
damus: &mut Damus,
|
damus: &mut Damus,
|
||||||
@@ -125,30 +148,12 @@ fn render_note_contents(
|
|||||||
for block in blocks.iter(note) {
|
for block in blocks.iter(note) {
|
||||||
match block.blocktype() {
|
match block.blocktype() {
|
||||||
BlockType::MentionBech32 => match block.as_mention().unwrap() {
|
BlockType::MentionBech32 => match block.as_mention().unwrap() {
|
||||||
|
Mention::Profile(profile) => {
|
||||||
|
mention_ui(damus, txn, profile.pubkey(), ui);
|
||||||
|
}
|
||||||
|
|
||||||
Mention::Pubkey(npub) => {
|
Mention::Pubkey(npub) => {
|
||||||
#[cfg(feature = "profiling")]
|
mention_ui(damus, txn, npub.pubkey(), ui);
|
||||||
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::Note(note) if options.has_note_previews() => {
|
Mention::Note(note) if options.has_note_previews() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user