From b07d4788884b3fa9be9fba24f396db5802c6c8fe Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 22 Nov 2024 19:51:04 +0200 Subject: [PATCH] Updated on 2026-08-14 --- .../domain/GetSingleWalletWarningsFactory.kt | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetSingleWalletWarningsFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetSingleWalletWarningsFactory.kt index 81e435fa5e..21f40750f2 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetSingleWalletWarningsFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetSingleWalletWarningsFactory.kt @@ -9,6 +9,7 @@ import com.tangem.domain.tokens.GetPrimaryCurrencyStatusUpdatesUseCase import com.tangem.domain.tokens.error.CurrencyStatusError import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.wallets.models.UserWallet +import com.tangem.domain.wallets.usecase.GetWalletsUseCase import com.tangem.domain.wallets.usecase.IsNeedToBackupUseCase import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotification import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents @@ -25,6 +26,7 @@ internal class GetSingleWalletWarningsFactory @Inject constructor( private val isReadyToShowRateAppUseCase: IsReadyToShowRateAppUseCase, private val isNeedToBackupUseCase: IsNeedToBackupUseCase, private val hasSingleWalletSignedHashesUseCase: HasSingleWalletSignedHashesUseCase, + private val getWalletsUseCase: GetWalletsUseCase, ) { private var readyForRateAppNotification = false @@ -36,22 +38,32 @@ internal class GetSingleWalletWarningsFactory @Inject constructor( flow = getPrimaryCurrencyStatusUpdatesUseCase(userWallet.walletId), flow2 = isReadyToShowRateAppUseCase().conflate(), flow3 = isNeedToBackupUseCase(userWallet.walletId).conflate(), - ) { primaryCurrencyStatus, isReadyToShowRating, isNeedToBackup -> + flow4 = getWalletsUseCase().conflate(), + ) { maybePrimaryCurrencyStatus, isReadyToShowRating, isNeedToBackup, userWallets -> readyForRateAppNotification = true buildList { - addCriticalNotifications(cardTypesResolver) - - addInformationalNotifications(cardTypesResolver, clickIntents) - - addWarningNotifications( - userWallet, - cardTypesResolver, - primaryCurrencyStatus, - isNeedToBackup, - clickIntents, + addCriticalNotifications( + cardTypesResolver = cardTypesResolver, ) - addRateTheAppNotification(isReadyToShowRating, clickIntents) + addInformationalNotifications( + userWallets = userWallets, + cardTypesResolver = cardTypesResolver, + clickIntents = clickIntents, + ) + + addWarningNotifications( + userWallet = userWallet, + cardTypesResolver = cardTypesResolver, + maybePrimaryCurrencyStatus = maybePrimaryCurrencyStatus, + isNeedToBackup = isNeedToBackup, + clickIntents = clickIntents, + ) + + addRateTheAppNotification( + isReadyToShowRating = isReadyToShowRating, + clickIntents = clickIntents, + ) }.toImmutableList() } } @@ -76,14 +88,19 @@ internal class GetSingleWalletWarningsFactory @Inject constructor( } private fun MutableList.addInformationalNotifications( + userWallets: List, cardTypesResolver: CardTypesResolver, clickIntents: WalletClickIntents, ) { + val userHasWalletOrWallet2 = userWallets.any { + val typesResolver = it.scanResponse.cardTypesResolver + typesResolver.isTangemWallet() || typesResolver.isWallet2() + } addIf( element = WalletNotification.NoteMigration( onClick = { clickIntents.onNoteMigrationButtonClick(NOTE_MIGRATION_URL) }, ), - condition = cardTypesResolver.isTangemNote(), + condition = cardTypesResolver.isTangemNote() && !userHasWalletOrWallet2, ) addIf(