Updated on 2026-08-14
This commit is contained in:
parent
a203465833
commit
9292c784cd
2 changed files with 14 additions and 8 deletions
|
|
@ -11,12 +11,12 @@ data class UserWalletModel(
|
|||
) {
|
||||
sealed interface Type {
|
||||
data class SingleCurrency(
|
||||
val blockchainName: String? = null,
|
||||
val blockchainName: String?,
|
||||
) : Type
|
||||
|
||||
data class MultiCurrency(
|
||||
val cardsInWallet: Int,
|
||||
val tokensCount: Int = 0,
|
||||
val tokensCount: Int,
|
||||
) : Type
|
||||
}
|
||||
}
|
||||
|
|
@ -66,10 +66,13 @@ internal object WalletSelectorReducer {
|
|||
return this.map { userWallet ->
|
||||
prevWallets
|
||||
.find { it.id == userWallet.walletId.stringValue }
|
||||
?.copy(
|
||||
name = userWallet.name,
|
||||
artworkUrl = userWallet.artworkUrl,
|
||||
)
|
||||
?.let {
|
||||
it.copy(
|
||||
name = userWallet.name,
|
||||
artworkUrl = userWallet.artworkUrl,
|
||||
type = userWallet.getType(prevType = it.type),
|
||||
)
|
||||
}
|
||||
?: with(userWallet) {
|
||||
UserWalletModel(
|
||||
id = walletId.stringValue,
|
||||
|
|
@ -90,15 +93,18 @@ internal object WalletSelectorReducer {
|
|||
}
|
||||
}
|
||||
|
||||
private fun UserWallet.getType(): UserWalletModel.Type {
|
||||
private fun UserWallet.getType(prevType: UserWalletModel.Type? = null): UserWalletModel.Type {
|
||||
return if (scanResponse.card.isMultiwalletAllowed) {
|
||||
UserWalletModel.Type.MultiCurrency(
|
||||
cardsInWallet = (scanResponse.card.backupStatus as? CardDTO.BackupStatus.Active)
|
||||
?.cardCount?.inc()
|
||||
?: 1,
|
||||
tokensCount = (prevType as? UserWalletModel.Type.MultiCurrency)?.tokensCount ?: 0,
|
||||
)
|
||||
} else {
|
||||
UserWalletModel.Type.SingleCurrency()
|
||||
UserWalletModel.Type.SingleCurrency(
|
||||
blockchainName = (prevType as? UserWalletModel.Type.SingleCurrency)?.blockchainName,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue