commit f9f8b3fe1b69eddc3cb5dfd28d8f3157310ab29c
parent 5ddd8660a324803fe75395f28ae79c99dc0fe8fb
Author: William Casarin <jb55@jb55.com>
Date: Wed, 23 Jul 2025 12:31:51 -0700
Merge remote-tracking branch 'github/pr/1023'
Diffstat:
10 files changed, 65 insertions(+), 30 deletions(-)
diff --git a/crates/notedeck/src/account/accounts.rs b/crates/notedeck/src/account/accounts.rs
@@ -207,6 +207,10 @@ impl Accounts {
self.cache.selected_mut()
}
+ pub fn get_selected_wallet(&self) -> Option<&ZapWallet> {
+ self.cache.selected().wallet.as_ref()
+ }
+
pub fn get_selected_wallet_mut(&mut self) -> Option<&mut ZapWallet> {
self.cache.selected_mut().wallet.as_mut()
}
diff --git a/crates/notedeck/src/lib.rs b/crates/notedeck/src/lib.rs
@@ -72,8 +72,8 @@ pub use unknowns::{get_unknown_note_ids, NoteRefsUnkIdAction, SingleUnkIdAction,
pub use urls::{supported_mime_hosted_at_url, SupportedMimeType, UrlMimes};
pub use user_account::UserAccount;
pub use wallet::{
- get_current_wallet, get_wallet_for, GlobalWallet, Wallet, WalletError, WalletType,
- WalletUIState, ZapWallet,
+ get_current_wallet, get_current_wallet_mut, get_wallet_for, GlobalWallet, Wallet, WalletError,
+ WalletType, WalletUIState, ZapWallet,
};
pub use zaps::{
get_current_default_msats, AnyZapState, DefaultZapError, DefaultZapMsats, NoteZapTarget,
diff --git a/crates/notedeck/src/note/mod.rs b/crates/notedeck/src/note/mod.rs
@@ -5,6 +5,7 @@ pub use action::{MediaAction, NoteAction, ScrollInfo, ZapAction, ZapTargetAmount
pub use context::{BroadcastContext, ContextSelection, NoteContextSelection};
use crate::Accounts;
+use crate::GlobalWallet;
use crate::JobPool;
use crate::Localization;
use crate::UnknownIds;
@@ -20,6 +21,7 @@ use std::fmt;
pub struct NoteContext<'d> {
pub ndb: &'d Ndb,
pub accounts: &'d Accounts,
+ pub global_wallet: &'d GlobalWallet,
pub i18n: &'d mut Localization,
pub img_cache: &'d mut Images,
pub note_cache: &'d mut NoteCache,
diff --git a/crates/notedeck/src/wallet.rs b/crates/notedeck/src/wallet.rs
@@ -24,7 +24,7 @@ pub fn get_wallet_for<'a>(
global_wallet.wallet.as_ref()
}
-pub fn get_current_wallet<'a>(
+pub fn get_current_wallet_mut<'a>(
accounts: &'a mut Accounts,
global_wallet: &'a mut GlobalWallet,
) -> Option<&'a mut ZapWallet> {
@@ -35,6 +35,17 @@ pub fn get_current_wallet<'a>(
Some(wallet)
}
+pub fn get_current_wallet<'a>(
+ accounts: &'a Accounts,
+ global_wallet: &'a GlobalWallet,
+) -> Option<&'a ZapWallet> {
+ let Some(wallet) = accounts.get_selected_wallet() else {
+ return global_wallet.wallet.as_ref();
+ };
+
+ Some(wallet)
+}
+
#[derive(Clone, Eq, PartialEq, Debug)]
pub enum WalletType {
Auto,
diff --git a/crates/notedeck_columns/src/nav.rs b/crates/notedeck_columns/src/nav.rs
@@ -520,6 +520,7 @@ fn render_nav_body(
unknown_ids: ctx.unknown_ids,
clipboard: ctx.clipboard,
i18n: ctx.i18n,
+ global_wallet: ctx.global_wallet,
};
match top {
Route::Timeline(kind) => {
diff --git a/crates/notedeck_columns/src/ui/note/post.rs b/crates/notedeck_columns/src/ui/note/post.rs
@@ -802,6 +802,7 @@ mod preview {
let mut note_context = NoteContext {
ndb: app.ndb,
accounts: app.accounts,
+ global_wallet: app.global_wallet,
img_cache: app.img_cache,
note_cache: app.note_cache,
zaps: app.zaps,
diff --git a/crates/notedeck_columns/src/ui/wallet.rs b/crates/notedeck_columns/src/ui/wallet.rs
@@ -1,6 +1,6 @@
use egui::{vec2, CornerRadius, Layout};
use notedeck::{
- get_current_wallet, tr, Accounts, DefaultZapMsats, GlobalWallet, Localization,
+ get_current_wallet_mut, tr, Accounts, DefaultZapMsats, GlobalWallet, Localization,
NotedeckTextStyle, PendingDefaultZapState, Wallet, WalletError, WalletUIState, ZapWallet,
};
@@ -103,7 +103,7 @@ impl WalletAction {
}
WalletAction::SetDefaultZapSats(new_default) => 's: {
let sats = {
- let Some(wallet) = get_current_wallet(accounts, global_wallet) else {
+ let Some(wallet) = get_current_wallet_mut(accounts, global_wallet) else {
break 's;
};
@@ -138,7 +138,7 @@ impl WalletAction {
global_wallet.save_wallet();
}
WalletAction::EditDefaultZaps => 's: {
- let Some(wallet) = get_current_wallet(accounts, global_wallet) else {
+ let Some(wallet) = get_current_wallet_mut(accounts, global_wallet) else {
break 's;
};
diff --git a/crates/notedeck_dave/src/ui/dave.rs b/crates/notedeck_dave/src/ui/dave.rs
@@ -220,6 +220,7 @@ impl<'a> DaveUi<'a> {
unknown_ids: ctx.unknown_ids,
clipboard: ctx.clipboard,
i18n: ctx.i18n,
+ global_wallet: ctx.global_wallet,
};
let txn = Transaction::new(note_context.ndb).unwrap();
diff --git a/crates/notedeck_ui/src/anim.rs b/crates/notedeck_ui/src/anim.rs
@@ -20,8 +20,13 @@ pub fn hover_expand(
(rect, size, response)
}
+#[inline]
+pub fn hover_small_size() -> f32 {
+ 14.0
+}
+
pub fn hover_expand_small(ui: &mut egui::Ui, id: egui::Id) -> (egui::Rect, f32, egui::Response) {
- let size = 10.0;
+ let size = hover_small_size();
let expand_size = 5.0;
let anim_speed = 0.05;
diff --git a/crates/notedeck_ui/src/note/mod.rs b/crates/notedeck_ui/src/note/mod.rs
@@ -13,9 +13,12 @@ use crate::{
pub use contents::{render_note_contents, render_note_preview, NoteContents};
pub use context::NoteContextButton;
+use notedeck::get_current_wallet;
use notedeck::note::MediaAction;
use notedeck::note::ZapTargetAmount;
use notedeck::ui::is_narrow;
+use notedeck::Accounts;
+use notedeck::GlobalWallet;
use notedeck::Images;
use notedeck::Localization;
pub use options::NoteOptions;
@@ -451,18 +454,13 @@ impl<'a, 'd> NoteView<'a, 'd> {
note_action = contents.action.or(note_action);
if self.options().contains(NoteOptions::ActionBar) {
- let zapper = {
- let cur_acc = self.note_context.accounts.get_selected_account();
- let has_wallet = cur_acc.wallet.is_some();
-
- has_wallet.then_some(Zapper {
- zaps: self.note_context.zaps,
- cur_acc: cur_acc.keypair(),
- })
- };
note_action = render_note_actionbar(
ui,
- zapper,
+ get_zapper(
+ self.note_context.accounts,
+ self.note_context.global_wallet,
+ self.note_context.zaps,
+ ),
self.note.id(),
self.note.pubkey(),
note_key,
@@ -531,20 +529,14 @@ impl<'a, 'd> NoteView<'a, 'd> {
note_action = contents.action.or(note_action);
- let zapper = {
- let cur_acc = self.note_context.accounts.get_selected_account();
- let has_wallet = cur_acc.wallet.is_some();
-
- has_wallet.then_some(Zapper {
- zaps: self.note_context.zaps,
- cur_acc: cur_acc.keypair(),
- })
- };
-
if self.options().contains(NoteOptions::ActionBar) {
note_action = render_note_actionbar(
ui,
- zapper,
+ get_zapper(
+ self.note_context.accounts,
+ self.note_context.global_wallet,
+ self.note_context.zaps,
+ ),
self.note.id(),
self.note.pubkey(),
note_key,
@@ -611,6 +603,20 @@ impl<'a, 'd> NoteView<'a, 'd> {
}
}
+fn get_zapper<'a>(
+ accounts: &'a Accounts,
+ global_wallet: &'a GlobalWallet,
+ zaps: &'a Zaps,
+) -> Option<Zapper<'a>> {
+ let has_wallet = get_current_wallet(accounts, global_wallet).is_some();
+ let cur_acc = accounts.get_selected_account();
+
+ has_wallet.then_some(Zapper {
+ zaps,
+ cur_acc: cur_acc.keypair(),
+ })
+}
+
fn get_reposted_note<'a>(ndb: &Ndb, txn: &'a Transaction, note: &Note) -> Option<Note<'a>> {
if note.kind() != 6 {
return None;
@@ -769,15 +775,19 @@ struct Zapper<'a> {
#[profiling::function]
fn render_note_actionbar(
ui: &mut egui::Ui,
- zapper: Option<Zapper>,
+ zapper: Option<Zapper<'_>>,
note_id: &[u8; 32],
note_pubkey: &[u8; 32],
note_key: NoteKey,
i18n: &mut Localization,
) -> egui::InnerResponse<Option<NoteAction>> {
ui.horizontal(|ui| {
+ 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);
@@ -893,7 +903,7 @@ fn quote_repost_button(
i18n: &mut Localization,
note_key: NoteKey,
) -> egui::Response {
- let size = 14.0;
+ let size = crate::anim::hover_small_size() + 4.0;
let expand_size = 5.0;
let anim_speed = 0.05;
let id = ui.id().with(("repost_anim", note_key));