From 72d696beb23899c3c2e8c70af42741bb93f7862b Mon Sep 17 00:00:00 2001 From: kernelkind Date: Sun, 31 Aug 2025 19:34:51 -0400 Subject: [PATCH] actionbar: reintroduce error messages there was a regression that caused error messages to not be displayed any more when zapping. Now when you click the zap button and the zap fails for some reason, the zap button will be replaced with an X and hovering over the X displays the error message Signed-off-by: kernelkind --- crates/notedeck_ui/src/note/mod.rs | 41 +++++++++++++++++------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/crates/notedeck_ui/src/note/mod.rs b/crates/notedeck_ui/src/note/mod.rs index 8247f967..4ac801ad 100644 --- a/crates/notedeck_ui/src/note/mod.rs +++ b/crates/notedeck_ui/src/note/mod.rs @@ -875,34 +875,39 @@ fn render_note_actionbar( zap_recipient: Pubkey::new(*note_pubkey), }; - if zap_state.is_err() { - action = Some(NoteAction::Zap(ZapAction::ClearError(target.clone()))); - } - - let zap_resp = { + { cur_acc.secret_key.as_ref()?; match zap_state { - Ok(any_zap_state) => ui.add(zap_button(i18n, any_zap_state, note_id)), + Ok(any_zap_state) => { + let zap_resp = ui.add(zap_button(i18n, any_zap_state, note_id)); + + if zap_resp.secondary_clicked() { + action = Some(NoteAction::Zap(ZapAction::CustomizeAmount(target.clone()))); + } + + if zap_resp.clicked() { + action = Some(NoteAction::Zap(ZapAction::Send(ZapTargetAmount { + target, + specified_msats: None, + }))); + } + + zap_resp + } Err(err) => { let (rect, _) = ui.allocate_at_least(egui::vec2(10.0, 10.0), egui::Sense::click()); - ui.add(x_button(rect)).on_hover_text(err.to_string()) + let x_button = ui.add(x_button(rect)).on_hover_text(err.to_string()); + + if x_button.clicked() { + action = Some(NoteAction::Zap(ZapAction::ClearError(target.clone()))); + } + x_button } } } .on_hover_cursor(egui::CursorIcon::PointingHand); - if zap_resp.secondary_clicked() { - action = Some(NoteAction::Zap(ZapAction::CustomizeAmount(target.clone()))); - } - - if zap_resp.clicked() { - action = Some(NoteAction::Zap(ZapAction::Send(ZapTargetAmount { - target, - specified_msats: None, - }))) - } - action }