fix missing zap button

Changelog-Fixed: Fix missing zap button
Fixes: 397bfce817 ("add `Accounts` to `NoteContext`")
Fixes: https://github.com/damus-io/notedeck/issues/1021
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-07-23 10:30:35 -07:00
parent 56cbf68ea5
commit ff0428550b
9 changed files with 54 additions and 28 deletions

View File

@@ -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()
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,