Updated on 2026-08-14
This commit is contained in:
parent
090e0964d4
commit
a9fbfc8a53
7 changed files with 272 additions and 107 deletions
|
|
@ -3,9 +3,9 @@ package com.tangem.domain.wallets.usecase
|
|||
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.models.wallet.isMultiCurrency
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import java.util.LinkedHashMap
|
||||
|
||||
/**
|
||||
* Use case for getting list of user wallets
|
||||
|
|
@ -22,9 +22,13 @@ class GetWalletsUseCase(
|
|||
operator fun invoke(): Flow<List<UserWallet>> = userWalletsListRepository.userWallets.map { requireNotNull(it) }
|
||||
|
||||
@Throws(IllegalArgumentException::class)
|
||||
fun invokeAsMap(): Flow<LinkedHashMap<UserWalletId, UserWallet>> = userWalletsListRepository.userWallets
|
||||
.map { requireNotNull(it) }
|
||||
.map { wallets ->
|
||||
fun invokeAsMap(isOnlyMultiCurrency: Boolean = true): Flow<LinkedHashMap<UserWalletId, UserWallet>> = invoke()
|
||||
.map { list ->
|
||||
val wallets = if (isOnlyMultiCurrency) {
|
||||
list.filter { wallet -> wallet.isMultiCurrency }
|
||||
} else {
|
||||
list
|
||||
}
|
||||
wallets.associateByTo(
|
||||
destination = linkedMapOf(),
|
||||
keySelector = { wallet -> wallet.walletId },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue