notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit e6d9de2b99825217f856a45543296a9af9ecd7f7
parent 9013a2e0675c715d70386a021c367e2eb6576102
Author: kernelkind <kernelkind@gmail.com>
Date:   Mon, 21 Apr 2025 16:56:22 -0400

wallet: helper method to get current wallet

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck/src/lib.rs | 3++-
Mcrates/notedeck/src/wallet.rs | 15+++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/crates/notedeck/src/lib.rs b/crates/notedeck/src/lib.rs @@ -64,7 +64,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_wallet_for_mut, GlobalWallet, Wallet, WalletError, WalletType, WalletUIState, ZapWallet, + get_current_wallet, get_wallet_for_mut, GlobalWallet, Wallet, WalletError, WalletType, + WalletUIState, ZapWallet, }; pub use zaps::{ AnyZapState, DefaultZapError, DefaultZapMsats, NoteZapTarget, NoteZapTargetOwned, diff --git a/crates/notedeck/src/wallet.rs b/crates/notedeck/src/wallet.rs @@ -24,6 +24,21 @@ pub fn get_wallet_for_mut<'a>( global_wallet.wallet.as_mut() } +pub fn get_current_wallet<'a>( + accounts: &'a mut Accounts, + global_wallet: &'a mut GlobalWallet, +) -> Option<&'a mut ZapWallet> { + let Some(acc) = accounts.get_selected_account_mut() else { + return global_wallet.wallet.as_mut(); + }; + + let Some(wallet) = &mut acc.wallet else { + return global_wallet.wallet.as_mut(); + }; + + Some(wallet) +} + #[derive(Clone, Eq, PartialEq, Debug)] pub enum WalletType { Auto,