don't expose mutable access to UserAccount
it's not preferable that the full mutable access is available to `ZapWallet`, but this PR is becoming too big already Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::account::relay::{
|
||||
};
|
||||
use crate::storage::AccountStorageWriter;
|
||||
use crate::user_account::UserAccountSerializable;
|
||||
use crate::{AccountStorage, MuteFun, SingleUnkIdAction, UnknownIds, UserAccount};
|
||||
use crate::{AccountStorage, MuteFun, SingleUnkIdAction, UnknownIds, UserAccount, ZapWallet};
|
||||
use enostr::{ClientMessage, FilledKeypair, Keypair, Pubkey, RelayPool};
|
||||
use nostrdb::{Ndb, Note, Transaction};
|
||||
|
||||
@@ -180,10 +180,14 @@ impl Accounts {
|
||||
self.get_selected_account().wallet.is_some()
|
||||
}
|
||||
|
||||
pub fn get_selected_account_mut(&mut self) -> &mut UserAccount {
|
||||
fn get_selected_account_mut(&mut self) -> &mut UserAccount {
|
||||
self.cache.selected_mut()
|
||||
}
|
||||
|
||||
pub fn get_selected_wallet_mut(&mut self) -> Option<&mut ZapWallet> {
|
||||
self.cache.selected_mut().wallet.as_mut()
|
||||
}
|
||||
|
||||
fn get_selected_account_data(&self) -> &AccountData {
|
||||
&self.cache.selected().data
|
||||
}
|
||||
|
||||
@@ -28,9 +28,7 @@ pub fn get_current_wallet<'a>(
|
||||
accounts: &'a mut Accounts,
|
||||
global_wallet: &'a mut GlobalWallet,
|
||||
) -> Option<&'a mut ZapWallet> {
|
||||
let acc = accounts.get_selected_account_mut();
|
||||
|
||||
let Some(wallet) = &mut acc.wallet else {
|
||||
let Some(wallet) = accounts.get_selected_wallet_mut() else {
|
||||
return global_wallet.wallet.as_mut();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user