Updated on 2026-08-14
This commit is contained in:
parent
749260cdef
commit
ed7a658e86
2 changed files with 22 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.markets.portfolio.impl.model
|
||||
|
||||
import arrow.core.getOrElse
|
||||
import com.tangem.blockchainsdk.compatibility.getTokenIdIfL2Network
|
||||
import com.tangem.common.ui.account.AccountTitleUM
|
||||
import com.tangem.common.ui.account.toUM
|
||||
|
|
@ -24,6 +25,8 @@ import com.tangem.domain.models.wallet.UserWalletId
|
|||
import com.tangem.domain.models.wallet.isMultiCurrency
|
||||
import com.tangem.domain.tokens.model.TokenActionsState
|
||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
import com.tangem.domain.yield.supply.models.YieldSupplyAvailability
|
||||
import com.tangem.domain.yield.supply.usecase.YieldSupplyGetAvailabilityUseCase
|
||||
import com.tangem.features.markets.portfolio.impl.loader.PortfolioData
|
||||
import com.tangem.features.markets.portfolio.impl.ui.state.MyPortfolioUM
|
||||
import com.tangem.features.markets.portfolio.impl.ui.state.MyPortfolioUM.Tokens.AddButtonState
|
||||
|
|
@ -48,6 +51,7 @@ internal class NewMarketsPortfolioDelegate @AssistedInject constructor(
|
|||
private val allAccountSupplier: MultiAccountStatusListSupplier,
|
||||
private val getCryptoCurrencyActionsUseCase: GetCryptoCurrencyActionsUseCaseV2,
|
||||
private val getUserWalletUseCase: GetUserWalletUseCase,
|
||||
private val yieldSupplyGetAvailabilityUseCase: YieldSupplyGetAvailabilityUseCase,
|
||||
isAccountsModeEnabledUseCase: IsAccountsModeEnabledUseCase,
|
||||
@Assisted private val scope: CoroutineScope,
|
||||
@Assisted private val token: TokenMarketParams,
|
||||
|
|
@ -113,10 +117,17 @@ internal class NewMarketsPortfolioDelegate @AssistedInject constructor(
|
|||
private fun contentFlow(portfolio: PortfoliosWithThisCurrency): Flow<MyPortfolioUM.Content> {
|
||||
fun Portfolio.actionsFoAccountCurrencies(): List<Flow<Pair<CryptoCurrency, TokenActionsState>>> =
|
||||
accountsWithAdded.map { account ->
|
||||
fun CryptoCurrencyStatus.actionsFlow() = getCryptoCurrencyActionsUseCase(
|
||||
accountId = account.accountStatus.account.accountId,
|
||||
currency = this.currency,
|
||||
).map { actionsState -> actionsState.cryptoCurrencyStatus.currency to actionsState }
|
||||
fun CryptoCurrencyStatus.actionsFlow(): Flow<Pair<CryptoCurrency, TokenActionsState>> = flow {
|
||||
val yieldSupplyAvailability = yieldSupplyGetAvailabilityUseCase(this@actionsFlow.currency)
|
||||
.getOrElse { YieldSupplyAvailability.Unavailable }
|
||||
emitAll(
|
||||
getCryptoCurrencyActionsUseCase(
|
||||
accountId = account.accountStatus.account.accountId,
|
||||
currency = this@actionsFlow.currency,
|
||||
yieldSupplyAvailability = yieldSupplyAvailability,
|
||||
).map { actionsState -> actionsState.cryptoCurrencyStatus.currency to actionsState },
|
||||
)
|
||||
}
|
||||
account.addedCurrency.map { it.actionsFlow() }
|
||||
}.flatten()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue