Updated on 2026-08-14

This commit is contained in:
Tangem 2026-04-09 20:26:31 +05:00
parent 58d7b0f393
commit 94c46ca16d
19 changed files with 61 additions and 126 deletions

View file

@ -8,6 +8,7 @@ import com.tangem.domain.account.status.usecase.GetAccountCurrencyStatusUseCase
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.models.account.AccountStatus
import com.tangem.domain.models.account.filterCryptoPortfolio
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
@ -42,14 +43,10 @@ internal class HotCryptoPortfolioDataLoader @Inject constructor(
.invokeSync(userWalletId, hotCryptoCurrencies)
.getOrNull()
.orEmpty()
val accountsWithHotCrypto = walletAccounts.accountStatuses.map { accountStatus ->
val account: AccountStatus.CryptoPortfolio = when (accountStatus) {
is AccountStatus.CryptoPortfolio -> accountStatus
is AccountStatus.Payment -> TODO("[REDACTED_JIRA]")
}
val addedHotCrypto = mapOfAddedCurrencies[account.account].orEmpty()
val accountsWithHotCrypto = walletAccounts.accountStatuses.filterCryptoPortfolio().map { accountStatus ->
val addedHotCrypto = mapOfAddedCurrencies[accountStatus.account].orEmpty()
HotCryptoPortfolioData.Account(
account = account,
account = accountStatus,
addedHotCrypto = addedHotCrypto,
)
}

View file

@ -247,20 +247,16 @@ internal class AvailableSwapPairsModel @Inject constructor(
val (appCurrency, isBalanceHidden) = appCurrencyAndBalanceHiding
val filterByQueryAccountList: Map<Account.CryptoPortfolio, List<CryptoCurrencyStatus>> = accountList
.filterCryptoPortfolio()
.associate { accountStatus ->
when (accountStatus) {
is AccountStatus.CryptoPortfolio -> {
val statuses = accountStatus.tokenList.flattenCurrencies()
.filterNot { status ->
status.currency.network.backendId == selectedStatus?.currency?.network?.backendId &&
status.currency.id.contractAddress == selectedStatus.currency.id.contractAddress
}
.filterByQuery(query = query)
accountStatus.account to statuses
val statuses = accountStatus.tokenList.flattenCurrencies()
.filterNot { status ->
status.currency.network.backendId == selectedStatus?.currency?.network?.backendId &&
status.currency.id.contractAddress == selectedStatus.currency.id.contractAddress
}
is AccountStatus.Payment -> TODO("[REDACTED_JIRA]")
}
.filterByQuery(query = query)
accountStatus.account to statuses
}
.filterValues { it.isNotEmpty() }

View file

@ -21,12 +21,9 @@ internal class SetLoadingAccountTokenListTransformer(
private val accountListItemConverter = LoadingAccountTokenItemConverter(appCurrency)
override fun transform(prevState: TokenListUM): TokenListUM {
val totalTokensCount = accountList.sumOf { account ->
when (account) {
is AccountStatus.CryptoPortfolio -> account.tokenList.flattenCurrencies().size
is AccountStatus.Payment -> TODO("[REDACTED_JIRA]")
}
}
val totalTokensCount = accountList
.filterCryptoPortfolio()
.sumOf { account -> account.tokenList.flattenCurrencies().size }
return prevState.copy(
availableItems = persistentListOf(),
@ -40,13 +37,10 @@ internal class SetLoadingAccountTokenListTransformer(
)
} else {
TokenListUMData.TokenList(
tokensList = accountList.flatMap { account ->
when (account) {
is AccountStatus.CryptoPortfolio -> LoadingTokenListItemConverter.convertList(
account.tokenList.flattenCurrencies().map(CryptoCurrencyStatus::currency),
)
is AccountStatus.Payment -> TODO("[REDACTED_JIRA]")
}
tokensList = accountList.filterCryptoPortfolio().flatMap { account ->
LoadingTokenListItemConverter.convertList(
account.tokenList.flattenCurrencies().map(CryptoCurrencyStatus::currency),
)
}.toPersistentList(),
totalTokensCount = totalTokensCount,
)

View file

@ -18,7 +18,6 @@ import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase
import com.tangem.domain.exchange.RampStateManager
import com.tangem.domain.models.TotalFiatBalance
import com.tangem.domain.models.account.Account
import com.tangem.domain.models.account.AccountStatus
import com.tangem.domain.models.account.filterCryptoPortfolio
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.settings.usercountry.GetUserCountryUseCase
@ -240,13 +239,8 @@ internal class OnrampTokenListModel @Inject constructor(
): Map<Account.CryptoPortfolio, List<CryptoCurrencyStatus>> = accountStatuses.asSequence()
.filterCryptoPortfolio()
.associate { accountStatus ->
when (accountStatus) {
is AccountStatus.CryptoPortfolio -> {
val filteredList = accountStatus.tokenList.flattenCurrencies().filterByQuery(query = query)
accountStatus.account to filteredList
}
is AccountStatus.Payment -> TODO("[REDACTED_JIRA]")
}
val filteredList = accountStatus.tokenList.flattenCurrencies().filterByQuery(query = query)
accountStatus.account to filteredList
}.filter { (_, value) -> value.isNotEmpty() }
private fun List<CryptoCurrencyStatus>.filterByQuery(query: String): List<CryptoCurrencyStatus> {