make UserAccount cloneable

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-07-17 19:24:01 -04:00
parent 049bb3e8bb
commit b9cae65b72
7 changed files with 20 additions and 4 deletions

View File

@@ -375,6 +375,7 @@ fn get_acc_from_storage(user_account_serializable: UserAccountSerializable) -> O
}) })
} }
#[derive(Clone)]
pub struct AccountData { pub struct AccountData {
pub(crate) relay: AccountRelayData, pub(crate) relay: AccountRelayData,
pub(crate) muted: AccountMutedData, pub(crate) muted: AccountMutedData,

View File

@@ -3,11 +3,13 @@ use std::collections::HashSet;
use enostr::Pubkey; use enostr::Pubkey;
use nostrdb::{Filter, Ndb, Note, NoteKey, Subscription, Transaction}; use nostrdb::{Filter, Ndb, Note, NoteKey, Subscription, Transaction};
#[derive(Clone)]
pub struct Contacts { pub struct Contacts {
pub filter: Filter, pub filter: Filter,
pub(super) state: ContactState, pub(super) state: ContactState,
} }
#[derive(Clone)]
pub enum ContactState { pub enum ContactState {
Unreceived, Unreceived,
Received { Received {

View File

@@ -5,6 +5,7 @@ use tracing::{debug, error};
use crate::Muted; use crate::Muted;
#[derive(Clone)]
pub(crate) struct AccountMutedData { pub(crate) struct AccountMutedData {
pub filter: Filter, pub filter: Filter,
pub muted: Arc<Muted>, pub muted: Arc<Muted>,

View File

@@ -7,6 +7,7 @@ use url::Url;
use crate::{AccountData, RelaySpec}; use crate::{AccountData, RelaySpec};
#[derive(Clone)]
pub(crate) struct AccountRelayData { pub(crate) struct AccountRelayData {
pub filter: Filter, pub filter: Filter,
pub local: BTreeSet<RelaySpec>, // used locally but not advertised pub local: BTreeSet<RelaySpec>, // used locally but not advertised

View File

@@ -6,6 +6,7 @@ use crate::{
AccountData, IsFollowing, AccountData, IsFollowing,
}; };
#[derive(Clone)]
pub struct UserAccount { pub struct UserAccount {
pub key: Keypair, pub key: Keypair,
pub wallet: Option<ZapWallet>, pub wallet: Option<ZapWallet>,

View File

@@ -60,6 +60,16 @@ pub struct Wallet {
balance: Option<Promise<Result<u64, NwcError>>>, balance: Option<Promise<Result<u64, NwcError>>>,
} }
impl Clone for Wallet {
fn clone(&self) -> Self {
Self {
uri: self.uri.clone(),
wallet: self.wallet.clone(),
balance: None,
}
}
}
#[derive(Clone)] #[derive(Clone)]
pub struct WalletSerializable { pub struct WalletSerializable {
pub uri: String, pub uri: String,
@@ -236,7 +246,7 @@ fn construct_global_wallet(wallet_handler: &TokenHandler) -> Option<ZapWallet> {
Some(wallet) Some(wallet)
} }
#[derive(Debug)] #[derive(Debug, Clone)]
pub struct ZapWallet { pub struct ZapWallet {
pub wallet: Wallet, pub wallet: Wallet,
pub default_zap: DefaultZapMsats, pub default_zap: DefaultZapMsats,

View File

@@ -4,7 +4,7 @@ use crate::get_current_wallet;
const DEFAULT_ZAP_MSATS: u64 = 10_000; const DEFAULT_ZAP_MSATS: u64 = 10_000;
#[derive(Debug, Default)] #[derive(Debug, Default, Clone)]
pub struct DefaultZapMsats { pub struct DefaultZapMsats {
pub msats: Option<u64>, pub msats: Option<u64>,
pub pending: PendingDefaultZapState, pub pending: PendingDefaultZapState,
@@ -83,7 +83,7 @@ impl TokenSerializable for UserZapMsats {
} }
} }
#[derive(Debug)] #[derive(Debug, Clone)]
pub struct PendingDefaultZapState { pub struct PendingDefaultZapState {
pub amount_sats: String, pub amount_sats: String,
pub error_message: Option<DefaultZapError>, pub error_message: Option<DefaultZapError>,
@@ -110,7 +110,7 @@ fn msats_to_sats_string(msats: u64) -> String {
(msats / 1000).to_string() (msats / 1000).to_string()
} }
#[derive(Debug)] #[derive(Debug, Clone)]
pub enum DefaultZapError { pub enum DefaultZapError {
InvalidUserInput, InvalidUserInput,
} }