feat(note-view): show note client

This commit is contained in:
Fernando López Guevara
2025-07-01 13:44:56 -03:00
parent cb5bd75236
commit 4bf75c95de
14 changed files with 113 additions and 53 deletions

View File

@@ -4,13 +4,14 @@ use crate::{
blur::imeta_blurhashes,
jobs::JobsCache,
note::{NoteAction, NoteOptions, NoteResponse, NoteView},
secondary_label,
};
use egui::{Color32, Hyperlink, RichText};
use nostrdb::{BlockType, Mention, Note, NoteKey, Transaction};
use tracing::warn;
use notedeck::{IsFollowing, NoteContext};
use notedeck::{IsFollowing, NoteCache, NoteContext};
use super::media::{find_renderable_media, image_carousel, RenderableMedia};
@@ -53,11 +54,28 @@ impl egui::Widget for &mut NoteContents<'_, '_> {
self.options,
self.jobs,
);
if self.options.contains(NoteOptions::ShowNoteClient) {
render_client(ui, self.note_context.note_cache, self.note);
}
self.action = result.action;
result.response
}
}
#[profiling::function]
fn render_client(ui: &mut egui::Ui, note_cache: &mut NoteCache, note: &Note) {
let cached_note = note_cache.cached_note_or_insert_mut(note.key().unwrap(), note);
match cached_note.client.as_deref() {
Some(client) if !client.is_empty() => {
ui.horizontal(|ui| {
secondary_label(ui, format!("via {}", client));
});
}
_ => return,
}
}
/// Render an inline note preview with a border. These are used when
/// notes are references within a note
#[allow(clippy::too_many_arguments)]