Updated on 2026-08-14
This commit is contained in:
parent
58d7b0f393
commit
94c46ca16d
19 changed files with 61 additions and 126 deletions
|
|
@ -3,7 +3,7 @@ package com.tangem.domain.nft.models
|
|||
import com.tangem.domain.models.account.Account
|
||||
|
||||
data class WalletNFTCollections(
|
||||
val collections: Map<Account, List<NFTCollections>>,
|
||||
val collections: Map<Account.CryptoPortfolio, List<NFTCollections>>,
|
||||
) {
|
||||
val flattenCollections by lazy { collections.values.flatten() }
|
||||
}
|
||||
|
|
@ -18,14 +18,18 @@ class GetNFTCollectionsUseCase(
|
|||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
operator fun invoke(userWalletId: UserWalletId): Flow<WalletNFTCollections> {
|
||||
return singleAccountListSupplier(userWalletId)
|
||||
.mapLatest { statusList -> statusList.accounts.mapNotNull(::flowOfNFTCollections) }
|
||||
.mapLatest { statusList ->
|
||||
statusList.accounts.filterIsInstance<Account.CryptoPortfolio>().mapNotNull(::flowOfNFTCollections)
|
||||
}
|
||||
.flatMapLatest { flows ->
|
||||
combine(flows) { WalletNFTCollections(it.toMap()) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun flowOfNFTCollections(account: Account): Flow<Pair<Account, List<NFTCollections>>>? {
|
||||
val currencies = (account as? Account.CryptoPortfolio)?.cryptoCurrencies.orEmpty()
|
||||
private fun flowOfNFTCollections(
|
||||
account: Account.CryptoPortfolio,
|
||||
): Flow<Pair<Account.CryptoPortfolio, List<NFTCollections>>>? {
|
||||
val currencies = account.cryptoCurrencies
|
||||
|
||||
if (currencies.isEmpty()) return null
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue