Updated on 2026-08-14
This commit is contained in:
parent
88b14a06ca
commit
f3e8ccb3be
4 changed files with 20 additions and 24 deletions
|
|
@ -20,7 +20,9 @@ sealed class WalletAction : Action {
|
|||
data class Failure(val error: TapError) : WalletAction()
|
||||
}
|
||||
|
||||
object LoadWallet : WalletAction() {
|
||||
data class LoadWallet(
|
||||
val wallet: Wallet, val artworkId: String?, val allowTopUp: Boolean
|
||||
) : WalletAction() {
|
||||
data class Success(val wallet: Wallet) : WalletAction()
|
||||
data class NoAccount(val amountToCreateAccount: String) : WalletAction()
|
||||
data class Failure(val errorMessage: String? = null) : WalletAction()
|
||||
|
|
@ -35,7 +37,7 @@ sealed class WalletAction : Action {
|
|||
|
||||
object UpdateWallet : WalletAction() {
|
||||
object ScheduleUpdatingWallet : WalletAction()
|
||||
data class Success(val wallet: Wallet, val topUpAllowed: Boolean) : WalletAction()
|
||||
data class Success(val wallet: Wallet) : WalletAction()
|
||||
data class Failure(val errorMessage: String? = null) : WalletAction()
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +52,7 @@ sealed class WalletAction : Action {
|
|||
object Failure : WalletAction()
|
||||
}
|
||||
|
||||
object DisablePayId: WalletAction()
|
||||
object DisablePayId : WalletAction()
|
||||
|
||||
data class LoadArtwork(val card: Card, val artworkId: String?) : WalletAction() {
|
||||
data class Success(val artwork: Artwork) : WalletAction()
|
||||
|
|
|
|||
|
|
@ -70,14 +70,8 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
|
||||
}
|
||||
is WalletAction.LoadWallet -> {
|
||||
val wallet = state.globalState.scanNoteResponse?.walletManager?.wallet
|
||||
val addressData = if (wallet == null) {
|
||||
null
|
||||
} else {
|
||||
AddressData(wallet.address, wallet.shareUrl, wallet.exploreUrl)
|
||||
}
|
||||
val currentArtworkId = state.globalState.scanNoteResponse?.verifyResponse?.artworkInfo?.id
|
||||
val cardImage = if (newState.cardImage?.artworkId == currentArtworkId) {
|
||||
val wallet = action.wallet
|
||||
val cardImage = if (newState.cardImage?.artworkId == action.artworkId) {
|
||||
newState.cardImage
|
||||
} else {
|
||||
null
|
||||
|
|
@ -87,15 +81,15 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
|
|||
cardImage = cardImage,
|
||||
currencyData = BalanceWidgetData(
|
||||
BalanceStatus.Loading,
|
||||
wallet?.blockchain?.fullName,
|
||||
currencySymbol = wallet?.blockchain?.currency,
|
||||
token = wallet?.token?.symbol?.let {
|
||||
wallet.blockchain.fullName,
|
||||
currencySymbol = wallet.blockchain.currency,
|
||||
token = wallet.token?.symbol?.let {
|
||||
TokenData("", tokenSymbol = it)
|
||||
}
|
||||
),
|
||||
addressData = addressData,
|
||||
mainButton = WalletMainButton.SendButton(false)
|
||||
|
||||
addressData = AddressData(wallet.address, wallet.shareUrl, wallet.exploreUrl),
|
||||
mainButton = WalletMainButton.SendButton(false),
|
||||
topUpState = TopUpState(allowed = action.allowTopUp)
|
||||
)
|
||||
}
|
||||
is WalletAction.LoadWallet.Success -> newState = onWalletLoaded(action.wallet, newState)
|
||||
|
|
@ -257,7 +251,6 @@ private fun onWalletLoaded(
|
|||
} else {
|
||||
BalanceStatus.VerifiedOnline
|
||||
}
|
||||
val topUpState = topUpAllowed?.let { TopUpState(topUpAllowed) } ?: walletState.topUpState
|
||||
return walletState.copy(
|
||||
state = ProgressState.Done, wallet = wallet,
|
||||
currencyData = BalanceWidgetData(
|
||||
|
|
@ -268,7 +261,6 @@ private fun onWalletLoaded(
|
|||
fiatAmount = fiatAmount
|
||||
),
|
||||
pendingTransactions = pendingTransactions.removeUnknownTransactions(),
|
||||
mainButton = WalletMainButton.SendButton(sendButtonEnabled),
|
||||
topUpState = topUpState
|
||||
mainButton = WalletMainButton.SendButton(sendButtonEnabled)
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue