commit c765b031e9bcab4c807636a60eb3a846fa69f314
parent 024cf3ef91b81e57e57b2c33f18db4f4eaa5b4ac
Author: William Casarin <jb55@jb55.com>
Date: Thu, 4 Sep 2025 15:33:53 -0700
ui/note: fix actionbar note responses
they are not responsive on android?
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 58 insertions(+), 48 deletions(-)
diff --git a/crates/notedeck_ui/src/note/mod.rs b/crates/notedeck_ui/src/note/mod.rs
@@ -832,35 +832,14 @@ struct Zapper<'a> {
cur_acc: KeypairUnowned<'a>,
}
-#[profiling::function]
-fn render_note_actionbar(
+fn zap_actionbar_button(
ui: &mut egui::Ui,
- zapper: Option<Zapper<'_>>,
note_id: &[u8; 32],
note_pubkey: &[u8; 32],
- note_key: NoteKey,
+ zapper: Option<Zapper<'_>>,
i18n: &mut Localization,
) -> Option<NoteAction> {
- let mut action = None;
-
- ui.set_min_height(26.0);
- ui.spacing_mut().item_spacing.x = 24.0;
-
- let reply_resp =
- reply_button(ui, i18n, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
-
- let quote_resp =
- quote_repost_button(ui, i18n, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
-
- let to_noteid = |id: &[u8; 32]| NoteId::new(*id);
- if reply_resp.clicked() {
- action = Some(NoteAction::Reply(to_noteid(note_id)));
- }
-
- if quote_resp.clicked() {
- action = Some(NoteAction::Quote(to_noteid(note_id)));
- }
-
+ let mut action: Option<NoteAction> = None;
let Zapper { zaps, cur_acc } = zapper?;
let zap_target = ZapTarget::Note(NoteZapTarget {
@@ -871,39 +850,37 @@ fn render_note_actionbar(
let zap_state = zaps.any_zap_state_for(cur_acc.pubkey.bytes(), zap_target);
let target = NoteZapTargetOwned {
- note_id: to_noteid(note_id),
+ note_id: NoteId::new(*note_id),
zap_recipient: Pubkey::new(*note_pubkey),
};
- {
- cur_acc.secret_key.as_ref()?;
+ cur_acc.secret_key.as_ref()?;
- match zap_state {
- Ok(any_zap_state) => {
- let zap_resp = ui.add(zap_button(i18n, any_zap_state, note_id));
+ match zap_state {
+ 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,
- })));
- }
+ if zap_resp.secondary_clicked() {
+ action = Some(NoteAction::Zap(ZapAction::CustomizeAmount(target.clone())));
+ }
- zap_resp
+ if zap_resp.clicked() {
+ action = Some(NoteAction::Zap(ZapAction::Send(ZapTargetAmount {
+ target,
+ specified_msats: None,
+ })));
}
- Err(err) => {
- let (rect, _) = ui.allocate_at_least(egui::vec2(10.0, 10.0), egui::Sense::click());
- 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
+ zap_resp
+ }
+ Err(err) => {
+ let (rect, _) = ui.allocate_at_least(egui::vec2(10.0, 10.0), egui::Sense::click());
+ 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);
@@ -912,6 +889,39 @@ fn render_note_actionbar(
}
#[profiling::function]
+fn render_note_actionbar(
+ ui: &mut egui::Ui,
+ zapper: Option<Zapper<'_>>,
+ note_id: &[u8; 32],
+ note_pubkey: &[u8; 32],
+ note_key: NoteKey,
+ i18n: &mut Localization,
+) -> Option<NoteAction> {
+ let mut action = None;
+
+ ui.set_min_height(26.0);
+ ui.spacing_mut().item_spacing.x = 24.0;
+
+ let reply_resp =
+ reply_button(ui, i18n, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
+
+ let quote_resp =
+ quote_repost_button(ui, i18n, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
+
+ if reply_resp.clicked() {
+ action = Some(NoteAction::Reply(NoteId::new(*note_id)));
+ }
+
+ if quote_resp.clicked() {
+ action = Some(NoteAction::Quote(NoteId::new(*note_id)));
+ }
+
+ action = zap_actionbar_button(ui, note_id, note_pubkey, zapper, i18n).or(action);
+
+ action
+}
+
+#[profiling::function]
fn render_notetime(
ui: &mut egui::Ui,
i18n: &mut Localization,