diff --git a/src/ui/profile/profile_preview_controller.rs b/src/ui/profile/profile_preview_controller.rs index 85a1d93..1c9b18e 100644 --- a/src/ui/profile/profile_preview_controller.rs +++ b/src/ui/profile/profile_preview_controller.rs @@ -135,6 +135,30 @@ pub fn show_with_nickname( Ok(ui_element(ui, &get_display_name(&profile))) } +pub fn show_with_selected_pfp( + app: &mut Damus, + ui: &mut egui::Ui, + ui_element: fn(ui: &mut egui::Ui, pfp: ProfilePic) -> egui::Response, +) -> Option { + let selected_account = app.account_manager.get_selected_account(); + if let Some(selected_account) = selected_account { + if let Ok(txn) = Transaction::new(&app.ndb) { + let profile = app + .ndb + .get_profile_by_pubkey(&txn, selected_account.pubkey.bytes()); + + if let Ok(profile) = profile { + return Some(ui_element( + ui, + ProfilePic::new(&mut app.img_cache, get_profile_url(&profile)), + )); + } + } + } + + None +} + pub fn show_with_pfp( app: &mut Damus, ui: &mut egui::Ui, diff --git a/src/ui/side_panel.rs b/src/ui/side_panel.rs index b424780..645cef9 100644 --- a/src/ui/side_panel.rs +++ b/src/ui/side_panel.rs @@ -71,18 +71,7 @@ impl<'a> DesktopSidePanel<'a> { } fn pfp_button(&mut self, ui: &mut egui::Ui) -> egui::Response { - let selected_account = self.app.account_manager.get_selected_account(); - if let Some(selected_account) = selected_account { - if let Some(response) = profile_preview_controller::show_with_pfp( - self.app, - ui, - &selected_account.pubkey.bytes().clone(), - show_pfp(), - ) { - return response; - } - } - + profile_preview_controller::show_with_selected_pfp(self.app, ui, show_pfp()); add_button_to_ui(ui, no_account_pfp()) } }