make Widget impl ProfilePic mutably

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-04-29 16:05:58 -04:00
parent 640bf742c0
commit 7d2112b472
10 changed files with 30 additions and 21 deletions

View File

@@ -400,13 +400,16 @@ impl<'a> NavTitle<'a> {
fn timeline_pfp(&mut self, ui: &mut egui::Ui, id: &TimelineKind, pfp_size: f32) {
let txn = Transaction::new(self.ndb).unwrap();
if let Some(pfp) = id
if let Some(mut pfp) = id
.pubkey()
.and_then(|pk| self.pubkey_pfp(&txn, pk.bytes(), pfp_size))
{
ui.add(pfp);
ui.add(&mut pfp);
} else {
ui.add(ProfilePic::new(self.img_cache, notedeck::profile::no_pfp_url()).size(pfp_size));
ui.add(
&mut ProfilePic::new(self.img_cache, notedeck::profile::no_pfp_url())
.size(pfp_size),
);
}
}
@@ -466,10 +469,13 @@ impl<'a> NavTitle<'a> {
fn show_profile(&mut self, ui: &mut egui::Ui, pubkey: &Pubkey, pfp_size: f32) {
let txn = Transaction::new(self.ndb).unwrap();
if let Some(pfp) = self.pubkey_pfp(&txn, pubkey.bytes(), pfp_size) {
ui.add(pfp);
if let Some(mut pfp) = self.pubkey_pfp(&txn, pubkey.bytes(), pfp_size) {
ui.add(&mut pfp);
} else {
ui.add(ProfilePic::new(self.img_cache, notedeck::profile::no_pfp_url()).size(pfp_size));
ui.add(
&mut ProfilePic::new(self.img_cache, notedeck::profile::no_pfp_url())
.size(pfp_size),
);
};
}

View File

@@ -142,11 +142,11 @@ impl<'a, 'd> PostView<'a, 'd> {
Some(ProfilePic::from_profile(self.note_context.img_cache, p)?.size(pfp_size))
});
if let Some(pfp) = poster_pfp {
ui.add(pfp);
if let Some(mut pfp) = poster_pfp {
ui.add(&mut pfp);
} else {
ui.add(
ProfilePic::new(self.note_context.img_cache, notedeck::profile::no_pfp_url())
&mut ProfilePic::new(self.note_context.img_cache, notedeck::profile::no_pfp_url())
.size(pfp_size),
);
}

View File

@@ -60,7 +60,7 @@ impl<'a> EditProfileView<'a> {
});
ui.put(
pfp_rect,
ProfilePic::new(self.img_cache, pfp_url)
&mut ProfilePic::new(self.img_cache, pfp_url)
.size(size)
.border(ProfilePic::border_stroke(ui)),
);

View File

@@ -148,7 +148,7 @@ impl<'a, 'd> ProfileView<'a, 'd> {
ui.horizontal(|ui| {
ui.put(
pfp_rect,
ProfilePic::new(
&mut ProfilePic::new(
self.note_context.img_cache,
get_profile_url(Some(&profile)),
)

View File

@@ -140,7 +140,7 @@ fn user_result<'a>(
let pfp_resp = ui.put(
icon_rect,
ProfilePic::new(cache, get_profile_url(Some(profile)))
&mut ProfilePic::new(cache, get_profile_url(Some(profile)))
.size(helper.scale_1d_pos(min_img_size)),
);