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...
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user