Updated on 2026-08-14
This commit is contained in:
parent
d19703e048
commit
5d206bd37f
17 changed files with 107 additions and 98 deletions
|
|
@ -13,6 +13,7 @@ import com.tangem.domain.tokens.GetTokenListUseCase
|
|||
import com.tangem.domain.tokens.ToggleTokenListGroupingUseCase
|
||||
import com.tangem.domain.tokens.ToggleTokenListSortingUseCase
|
||||
import com.tangem.domain.tokens.model.TokenList
|
||||
import com.tangem.domain.tokens.model.TotalFiatBalance
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.featuretoggle.WalletFeatureToggles
|
||||
import com.tangem.feature.wallet.presentation.organizetokens.analytics.PortfolioOrganizeTokensAnalyticsEvent
|
||||
|
|
@ -191,7 +192,7 @@ internal class OrganizeTokensViewModel @Inject constructor(
|
|||
} else {
|
||||
val maybeTokenList = getTokenListUseCase.launch(userWalletId)
|
||||
.first { maybeTokenList ->
|
||||
maybeTokenList.getOrNull()?.totalFiatBalance !is TokenList.FiatBalance.Loading
|
||||
maybeTokenList.getOrNull()?.totalFiatBalance !is TotalFiatBalance.Loading
|
||||
}
|
||||
|
||||
maybeTokenList.getOrElse { error ->
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.tangem.domain.analytics.model.WalletBalanceState
|
|||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.NetworkGroup
|
||||
import com.tangem.domain.tokens.model.TokenList
|
||||
import com.tangem.domain.tokens.model.TotalFiatBalance
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent.Basic
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent.MainScreen
|
||||
|
|
@ -35,7 +36,7 @@ internal class TokenListAnalyticsSender @Inject constructor(
|
|||
suspend fun send(displayedUiState: WalletState?, userWallet: UserWallet, tokenList: TokenList) {
|
||||
if (screenLifecycleProvider.isBackgroundState.value) return
|
||||
if (displayedUiState == null || displayedUiState.pullToRefreshConfig.isRefreshing) return
|
||||
if (tokenList.totalFiatBalance is TokenList.FiatBalance.Loading) return
|
||||
if (tokenList.totalFiatBalance is TotalFiatBalance.Loading) return
|
||||
|
||||
val currenciesStatuses = getCurrenciesStatuses(tokenList)
|
||||
|
||||
|
|
@ -52,7 +53,7 @@ internal class TokenListAnalyticsSender @Inject constructor(
|
|||
}
|
||||
|
||||
private fun sendBalanceLoadedEventIfNeeded(
|
||||
fiatBalance: TokenList.FiatBalance,
|
||||
fiatBalance: TotalFiatBalance,
|
||||
currenciesStatuses: List<CryptoCurrencyStatus>,
|
||||
) {
|
||||
createCardBalanceState(fiatBalance, currenciesStatuses)?.let { balanceState ->
|
||||
|
|
@ -61,13 +62,13 @@ internal class TokenListAnalyticsSender @Inject constructor(
|
|||
}
|
||||
|
||||
private fun createCardBalanceState(
|
||||
fiatBalance: TokenList.FiatBalance,
|
||||
fiatBalance: TotalFiatBalance,
|
||||
currenciesStatuses: List<CryptoCurrencyStatus>,
|
||||
): AnalyticsParam.CardBalanceState? {
|
||||
return when (fiatBalance) {
|
||||
is TokenList.FiatBalance.Failed -> getCardBalanceState(currenciesStatuses)
|
||||
is TokenList.FiatBalance.Loaded -> getCardBalanceState(fiatBalance)
|
||||
is TokenList.FiatBalance.Loading -> null
|
||||
is TotalFiatBalance.Failed -> getCardBalanceState(currenciesStatuses)
|
||||
is TotalFiatBalance.Loaded -> getCardBalanceState(fiatBalance)
|
||||
is TotalFiatBalance.Loading -> null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +126,7 @@ internal class TokenListAnalyticsSender @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun getCardBalanceState(fiatBalance: TokenList.FiatBalance.Loaded): AnalyticsParam.CardBalanceState {
|
||||
private fun getCardBalanceState(fiatBalance: TotalFiatBalance.Loaded): AnalyticsParam.CardBalanceState {
|
||||
return if (fiatBalance.amount > BigDecimal.ZERO) {
|
||||
AnalyticsParam.CardBalanceState.Full
|
||||
} else {
|
||||
|
|
@ -135,7 +136,7 @@ internal class TokenListAnalyticsSender @Inject constructor(
|
|||
|
||||
private suspend fun sendToppedUpEventIfNeeded(
|
||||
userWallet: UserWallet,
|
||||
fiatBalance: TokenList.FiatBalance,
|
||||
fiatBalance: TotalFiatBalance,
|
||||
currenciesStatuses: List<CryptoCurrencyStatus>,
|
||||
) {
|
||||
val balanceState = getWalletBalanceState(fiatBalance) ?: return
|
||||
|
|
@ -157,17 +158,17 @@ internal class TokenListAnalyticsSender @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun getWalletBalanceState(fiatBalance: TokenList.FiatBalance): WalletBalanceState? {
|
||||
private fun getWalletBalanceState(fiatBalance: TotalFiatBalance): WalletBalanceState? {
|
||||
return when (fiatBalance) {
|
||||
is TokenList.FiatBalance.Failed -> WalletBalanceState.Error
|
||||
is TokenList.FiatBalance.Loaded -> {
|
||||
is TotalFiatBalance.Failed -> WalletBalanceState.Error
|
||||
is TotalFiatBalance.Loaded -> {
|
||||
if (fiatBalance.amount > BigDecimal.ZERO) {
|
||||
WalletBalanceState.ToppedUp
|
||||
} else {
|
||||
WalletBalanceState.Empty
|
||||
}
|
||||
}
|
||||
is TokenList.FiatBalance.Loading -> null
|
||||
is TotalFiatBalance.Loading -> null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.tangem.feature.wallet.presentation.wallet.state.transformers.convert
|
|||
|
||||
import com.tangem.core.ui.utils.BigDecimalFormatter
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.tokens.model.TokenList
|
||||
import com.tangem.domain.tokens.model.TotalFiatBalance
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletAdditionalInfoFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.getCardsCount
|
||||
|
|
@ -10,16 +10,16 @@ import com.tangem.feature.wallet.presentation.wallet.state.model.WalletCardState
|
|||
import com.tangem.utils.converter.Converter
|
||||
|
||||
internal class MultiWalletCardStateConverter(
|
||||
private val fiatBalance: TokenList.FiatBalance,
|
||||
private val fiatBalance: TotalFiatBalance,
|
||||
private val selectedWallet: UserWallet,
|
||||
private val appCurrency: AppCurrency,
|
||||
) : Converter<WalletCardState, WalletCardState> {
|
||||
|
||||
override fun convert(value: WalletCardState): WalletCardState {
|
||||
return when (fiatBalance) {
|
||||
is TokenList.FiatBalance.Loading -> value.toLoadingState()
|
||||
is TokenList.FiatBalance.Failed -> value.toErrorState()
|
||||
is TokenList.FiatBalance.Loaded -> value.toWalletCardState(fiatBalance)
|
||||
is TotalFiatBalance.Loading -> value.toLoadingState()
|
||||
is TotalFiatBalance.Failed -> value.toErrorState()
|
||||
is TotalFiatBalance.Loaded -> value.toWalletCardState(fiatBalance)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ internal class MultiWalletCardStateConverter(
|
|||
)
|
||||
}
|
||||
|
||||
private fun WalletCardState.toWalletCardState(fiatBalance: TokenList.FiatBalance.Loaded): WalletCardState {
|
||||
private fun WalletCardState.toWalletCardState(fiatBalance: TotalFiatBalance.Loaded): WalletCardState {
|
||||
return WalletCardState.Content(
|
||||
id = id,
|
||||
title = title,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.tangem.domain.common.util.cardTypesResolver
|
|||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.NetworkGroup
|
||||
import com.tangem.domain.tokens.model.TokenList
|
||||
import com.tangem.domain.tokens.model.TotalFiatBalance
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTokensListState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTokensListState.TokensListItemState
|
||||
|
|
@ -79,7 +80,7 @@ internal class TokenListStateConverter(
|
|||
private fun getOrganizeTokensButtonState(currenciesSize: Int): WalletOrganizeTokensButtonConfig? {
|
||||
return if (currenciesSize > 1 && !isSingleCurrencyWalletWithToken()) {
|
||||
WalletOrganizeTokensButtonConfig(
|
||||
isEnabled = tokenList.totalFiatBalance !is TokenList.FiatBalance.Loading,
|
||||
isEnabled = tokenList.totalFiatBalance !is TotalFiatBalance.Loading,
|
||||
onClick = clickIntents::onOrganizeTokensClick,
|
||||
)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.tangem.domain.tokens.RunPolkadotAccountHealthCheckUseCase
|
|||
import com.tangem.domain.tokens.error.TokenListError
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.TokenList
|
||||
import com.tangem.domain.tokens.model.TotalFiatBalance
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.featuretoggle.WalletFeatureToggles
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAnalyticsSender
|
||||
|
|
@ -65,7 +66,7 @@ internal class MultiWalletTokenListSubscriber(
|
|||
}
|
||||
|
||||
private fun checkNeedSorting(tokenList: TokenList): Boolean {
|
||||
return tokenList.totalFiatBalance !is TokenList.FiatBalance.Loading &&
|
||||
return tokenList.totalFiatBalance !is TotalFiatBalance.Loading &&
|
||||
tokenList.sortedBy == TokenList.SortType.BALANCE
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue