Updated on 2026-08-14
This commit is contained in:
parent
bd0adfea6f
commit
7d7b6106a0
8 changed files with 134 additions and 8 deletions
|
|
@ -17,6 +17,12 @@ fun List<WalletData>.calculateTotalFiatAmount(): BigDecimal {
|
|||
.reduce(BigDecimal::plus)
|
||||
}
|
||||
|
||||
fun List<WalletData>.calculateTotalCryptoAmount(): BigDecimal {
|
||||
return this
|
||||
.map { it.currencyData.amount ?: BigDecimal.ZERO }
|
||||
.reduce(BigDecimal::plus)
|
||||
}
|
||||
|
||||
private fun List<WalletData>.mapToProgressState(): List<ProgressState> {
|
||||
return this.map { wallet ->
|
||||
if (wallet.fiatRate == null) ProgressState.Error
|
||||
|
|
@ -25,12 +31,15 @@ private fun List<WalletData>.mapToProgressState(): List<ProgressState> {
|
|||
BalanceStatus.VerifiedOnline,
|
||||
BalanceStatus.SameCurrencyTransactionInProgress,
|
||||
BalanceStatus.TransactionInProgress,
|
||||
BalanceStatus.NoAccount -> ProgressState.Done
|
||||
BalanceStatus.NoAccount,
|
||||
-> ProgressState.Done
|
||||
BalanceStatus.Unreachable,
|
||||
BalanceStatus.EmptyCard,
|
||||
BalanceStatus.UnknownBlockchain -> ProgressState.Error
|
||||
BalanceStatus.UnknownBlockchain,
|
||||
-> ProgressState.Error
|
||||
BalanceStatus.Loading,
|
||||
null -> ProgressState.Loading
|
||||
null,
|
||||
-> ProgressState.Loading
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -41,20 +50,24 @@ private infix fun ProgressState.or(newState: ProgressState): ProgressState {
|
|||
ProgressState.Loading,
|
||||
ProgressState.Refreshing,
|
||||
ProgressState.Error,
|
||||
ProgressState.Done -> this
|
||||
ProgressState.Done,
|
||||
-> this
|
||||
}
|
||||
ProgressState.Done,
|
||||
ProgressState.Error -> when (newState) {
|
||||
ProgressState.Error,
|
||||
-> when (newState) {
|
||||
ProgressState.Loading,
|
||||
ProgressState.Refreshing,
|
||||
ProgressState.Error -> newState
|
||||
ProgressState.Error,
|
||||
-> newState
|
||||
ProgressState.Done -> this
|
||||
}
|
||||
ProgressState.Refreshing -> when (newState) {
|
||||
ProgressState.Loading -> this
|
||||
ProgressState.Refreshing,
|
||||
ProgressState.Error,
|
||||
ProgressState.Done -> newState
|
||||
ProgressState.Done,
|
||||
-> newState
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ import coil.size.Scale
|
|||
import com.tangem.domain.common.TapWorkarounds.isSaltPay
|
||||
import com.tangem.tap.MainActivity
|
||||
import com.tangem.tap.common.analytics.Analytics
|
||||
import com.tangem.tap.common.analytics.converters.BasicSignInEventConverter
|
||||
import com.tangem.tap.common.analytics.events.MainScreen
|
||||
import com.tangem.tap.common.analytics.events.Portfolio
|
||||
import com.tangem.tap.common.extensions.show
|
||||
|
|
@ -33,6 +34,7 @@ import com.tangem.tap.features.wallet.redux.ErrorType
|
|||
import com.tangem.tap.features.wallet.redux.ProgressState
|
||||
import com.tangem.tap.features.wallet.redux.WalletAction
|
||||
import com.tangem.tap.features.wallet.redux.WalletState
|
||||
import com.tangem.tap.features.wallet.redux.reducers.calculateTotalCryptoAmount
|
||||
import com.tangem.tap.features.wallet.ui.adapters.WarningMessagesAdapter
|
||||
import com.tangem.tap.features.wallet.ui.wallet.MultiWalletView
|
||||
import com.tangem.tap.features.wallet.ui.wallet.SaltPaySingleWalletView
|
||||
|
|
@ -119,6 +121,7 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
|
|||
override fun newState(state: WalletState) {
|
||||
if (activity == null || view == null) return
|
||||
|
||||
handleBasicAnalyticsEvent(state)
|
||||
val isSaltPay = store.state.globalState.scanResponse?.card?.isSaltPay == true
|
||||
|
||||
when {
|
||||
|
|
@ -226,4 +229,15 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
|
|||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
if (store.state.walletState.shouldShowDetails) inflater.inflate(R.menu.menu_wallet, menu)
|
||||
}
|
||||
|
||||
private fun handleBasicAnalyticsEvent(state: WalletState) {
|
||||
if (state.walletsData.isEmpty()) return
|
||||
val scanResponse = store.state.globalState.scanResponse ?: return
|
||||
val totalBalanceState = state.totalBalance?.state ?: return
|
||||
|
||||
val totalCryptoAmount = state.walletsData.calculateTotalCryptoAmount()
|
||||
BasicSignInEventConverter(scanResponse, totalBalanceState, totalCryptoAmount).convert(null)?.let {
|
||||
Analytics.send(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue