notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 5c8fba220c79f26a5a633eaf7d3f8700992362e4
parent c4084a1fb5d03a97c220fd01097791492671a20f
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 22 Apr 2025 10:48:48 -0700

ui: add ProfilePic::from_profile_or_default

This is yet another helper, I really need to clean this
ui widget up in terms of its possible constructors...

Diffstat:
Mcrates/notedeck_ui/src/profile/picture.rs | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/crates/notedeck_ui/src/profile/picture.rs b/crates/notedeck_ui/src/profile/picture.rs @@ -43,6 +43,19 @@ impl<'cache, 'url> ProfilePic<'cache, 'url> { .map(|url| ProfilePic::new(cache, url)) } + pub fn from_profile_or_default( + cache: &'cache mut Images, + profile: Option<&nostrdb::ProfileRecord<'url>>, + ) -> Self { + let url = profile + .map(|p| p.record()) + .and_then(|p| p.profile()) + .and_then(|p| p.picture()) + .unwrap_or(notedeck::profile::no_pfp_url()); + + ProfilePic::new(cache, url) + } + #[inline] pub fn default_size() -> i8 { 38