From 58b3b092e64884ebedd7fb4aa982b2ccfea8add1 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 12 Dec 2024 18:35:25 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../tokens/GetCurrencyWarningsUseCase.kt | 23 ++++--------------- .../viewmodels/TokenDetailsViewModel.kt | 1 + 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt index 6f2c349a7c..3e54e19951 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt @@ -50,6 +50,7 @@ class GetCurrencyWarningsUseCase( stakingRepository = stakingRepository, userWalletId = userWalletId, ) + // don't add here notifications that require async requests return combine( getCoinRelatedWarnings( userWalletId = userWalletId, @@ -62,14 +63,8 @@ class GetCurrencyWarningsUseCase( flowOf(currencyChecksRepository.getRentInfoWarning(userWalletId, currencyStatus)), flowOf(currencyChecksRepository.getExistentialDeposit(userWalletId, currency.network)), flowOf(currencyChecksRepository.getFeeResourceAmount(userWalletId, currency.network)), - getSwapPromoNotificationWarning( - operations = operations, - userWalletId = userWalletId, - currencyStatus = currencyStatus, - ).conflate(), - ) { coinRelatedWarnings, maybeRentWarning, maybeEdWarning, maybeFeeResource, maybeSwapPromo -> + ) { coinRelatedWarnings, maybeRentWarning, maybeEdWarning, maybeFeeResource -> setOfNotNull( - maybeSwapPromo, maybeRentWarning, maybeEdWarning?.let { getExistentialDepositWarning(currency, it) }, maybeFeeResource?.let { getFeeResourceWarning(it) }, @@ -80,19 +75,11 @@ class GetCurrencyWarningsUseCase( getAssetRequirementsWarning(userWalletId = userWalletId, currency = currency), getMigrationFromMaticToPolWarning(currency), ) - } - .onEmpty { - setOfNotNull( - getNetworkUnavailableWarning(currencyStatus), - getNetworkNoAccountWarning(currencyStatus), - getBeaconChainShutdownWarning(currency.network.id), - getAssetRequirementsWarning(userWalletId = userWalletId, currency = currency), - getMigrationFromMaticToPolWarning(currency), - ) - } - .flowOn(dispatchers.io) + }.flowOn(dispatchers.io) } + // disabled for now, don't use it directly in combine() to avoid blocking other notifications + @Suppress("UnusedPrivateMember") private suspend fun getSwapPromoNotificationWarning( operations: CurrenciesStatusesOperations, userWalletId: UserWalletId, diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt index f41620317c..1de3357e01 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt @@ -240,6 +240,7 @@ internal class TokenDetailsViewModel @Inject constructor( currentCryptoCurrencyStatus?.let { cryptoCurrencyStatus = it updateButtons(it) + updateWarnings(it) } } }