fix: profile loading

This commit is contained in:
2024-10-17 22:31:12 +01:00
parent 117968bd17
commit 948276eb65
4 changed files with 23 additions and 10 deletions

View File

@ -1,3 +1,4 @@
use crate::route::RouteServices;
use crate::services::image_cache::ImageCache;
use crate::services::ndb_wrapper::SubWrapper;
use egui::{Color32, Image, Pos2, Response, Rounding, Sense, Ui, Vec2, Widget};
@ -36,6 +37,15 @@ impl<'a> Avatar<'a> {
}
}
pub fn pubkey(pk: &[u8; 32], svc: &'a RouteServices<'a>) -> Self {
let (p, sub) = svc.ndb.fetch_profile(svc.tx, pk);
Self {
image: p.and_then(|p| p.picture().and_then(|p| Some(svc.img_cache.load(p)))),
sub,
size: None,
}
}
pub fn size(mut self, size: f32) -> Self {
self.size = Some(size);
self