diff --git a/crates/notedeck_ui/src/mention.rs b/crates/notedeck_ui/src/mention.rs index 9dd46b3..e6e1c6e 100644 --- a/crates/notedeck_ui/src/mention.rs +++ b/crates/notedeck_ui/src/mention.rs @@ -42,7 +42,7 @@ impl<'a> Mention<'a> { self } - pub fn show(self, ui: &mut egui::Ui) -> egui::InnerResponse> { + pub fn show(self, ui: &mut egui::Ui) -> Option { mention_ui( self.ndb, self.img_cache, @@ -55,12 +55,6 @@ impl<'a> Mention<'a> { } } -impl egui::Widget for Mention<'_> { - fn ui(self, ui: &mut egui::Ui) -> egui::Response { - self.show(ui).response - } -} - #[allow(clippy::too_many_arguments)] #[profiling::function] fn mention_ui( @@ -71,40 +65,38 @@ fn mention_ui( ui: &mut egui::Ui, size: f32, selectable: bool, -) -> egui::InnerResponse> { +) -> Option { let link_color = ui.visuals().hyperlink_color; - ui.horizontal(|ui| { - let profile = ndb.get_profile_by_pubkey(txn, pk).ok(); + let profile = ndb.get_profile_by_pubkey(txn, pk).ok(); - let name: String = format!( - "@{}", - get_display_name(profile.as_ref()).username_or_displayname() - ); + let name: String = format!( + "@{}", + get_display_name(profile.as_ref()).username_or_displayname() + ); - let resp = ui.add( - egui::Label::new(egui::RichText::new(name).color(link_color).size(size)) - .sense(Sense::click()) - .selectable(selectable), - ); + let resp = ui.add( + egui::Label::new(egui::RichText::new(name).color(link_color).size(size)) + .sense(Sense::click()) + .selectable(selectable), + ); - let note_action = if resp.clicked() { - show_pointer(ui); - Some(NoteAction::Profile(Pubkey::new(*pk))) - } else if resp.hovered() { - show_pointer(ui); - None - } else { - None - }; + let note_action = if resp.clicked() { + show_pointer(ui); + Some(NoteAction::Profile(Pubkey::new(*pk))) + } else if resp.hovered() { + show_pointer(ui); + None + } else { + None + }; - if let Some(rec) = profile.as_ref() { - resp.on_hover_ui_at_pointer(|ui| { - ui.set_max_width(300.0); - ui.add(ProfilePreview::new(rec, img_cache)); - }); - } + if let Some(rec) = profile.as_ref() { + resp.on_hover_ui_at_pointer(|ui| { + ui.set_max_width(300.0); + ui.add(ProfilePreview::new(rec, img_cache)); + }); + } - note_action - }) + note_action } diff --git a/crates/notedeck_ui/src/note/contents.rs b/crates/notedeck_ui/src/note/contents.rs index fa0ce38..cd3dbb1 100644 --- a/crates/notedeck_ui/src/note/contents.rs +++ b/crates/notedeck_ui/src/note/contents.rs @@ -158,8 +158,8 @@ pub fn render_note_contents( txn, profile.pubkey(), ) - .show(ui) - .inner; + .show(ui); + if act.is_some() { note_action = act; } @@ -172,8 +172,8 @@ pub fn render_note_contents( txn, npub.pubkey(), ) - .show(ui) - .inner; + .show(ui); + if act.is_some() { note_action = act; } diff --git a/crates/notedeck_ui/src/note/reply_description.rs b/crates/notedeck_ui/src/note/reply_description.rs index 6159641..43c459c 100644 --- a/crates/notedeck_ui/src/note/reply_description.rs +++ b/crates/notedeck_ui/src/note/reply_description.rs @@ -72,8 +72,7 @@ pub fn reply_desc( ) .size(size) .selectable(selectable) - .show(ui) - .inner; + .show(ui); if action.is_some() { note_action = action; @@ -96,8 +95,7 @@ pub fn reply_desc( ) .size(size) .selectable(selectable) - .show(ui) - .inner; + .show(ui); if action.is_some() { note_action = action; @@ -119,8 +117,7 @@ pub fn reply_desc( ) .size(size) .selectable(selectable) - .show(ui) - .inner; + .show(ui); if action.is_some() { note_action = action; @@ -144,8 +141,7 @@ pub fn reply_desc( ) .size(size) .selectable(selectable) - .show(ui) - .inner; + .show(ui); if action.is_some() { note_action = action; @@ -166,8 +162,7 @@ pub fn reply_desc( ) .size(size) .selectable(selectable) - .show(ui) - .inner; + .show(ui); if action.is_some() { note_action = action;