From 1f0d1e43aba68a0f76c27c24b9bac2ac3383c7ae Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 23 Dec 2025 17:05:52 +0700 Subject: [PATCH] Updated on 2026-08-14 --- .../details/model/UserWalletListModel.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/features/details/impl/src/main/kotlin/com/tangem/features/details/model/UserWalletListModel.kt b/features/details/impl/src/main/kotlin/com/tangem/features/details/model/UserWalletListModel.kt index badebd605e..d06b8f5e19 100644 --- a/features/details/impl/src/main/kotlin/com/tangem/features/details/model/UserWalletListModel.kt +++ b/features/details/impl/src/main/kotlin/com/tangem/features/details/model/UserWalletListModel.kt @@ -23,10 +23,7 @@ import com.tangem.features.wallet.utils.UserWalletsFetcher import com.tangem.utils.coroutines.CoroutineDispatcherProvider import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.update +import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch import timber.log.Timber import javax.inject.Inject @@ -64,13 +61,18 @@ internal class UserWalletListModel @Inject constructor( ) init { - combine( - flow = userWalletsFetcher.userWallets, - flow2 = shouldSaveUserWalletsUseCase(), - flow3 = isWalletSavingInProgress, - ) { userWallets, shouldSaveUserWallets, isWalletSavingInProgress -> - updateState(userWallets, shouldSaveUserWallets, isWalletSavingInProgress) - }.launchIn(modelScope) + modelScope.launch { + val userWalletsFlow = userWalletsFetcher.userWallets.stateIn(this) + state.update { value -> value.copy(userWallets = userWalletsFlow.value) } + + combine( + flow = userWalletsFlow, + flow2 = shouldSaveUserWalletsUseCase(), + flow3 = isWalletSavingInProgress, + ) { userWallets, shouldSaveUserWallets, isWalletSavingInProgress -> + updateState(userWallets, shouldSaveUserWallets, isWalletSavingInProgress) + }.collect() + } } private fun updateState(