diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletWarningsAnalyticsSender.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletWarningsAnalyticsSender.kt index 8c1eaa8cdf..39c028fe87 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletWarningsAnalyticsSender.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/analytics/utils/WalletWarningsAnalyticsSender.kt @@ -144,6 +144,7 @@ internal class WalletWarningsAnalyticsSender @Inject constructor( is WalletNotificationUM.TangemPayRefreshNeeded, WalletNotificationUM.TangemPayUnreachable, is WalletNotificationUM.YieldBoostPromo, + is WalletNotificationUM.AssetsDiscoveryCompleted, -> null } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetWalletNotificationsFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetWalletNotificationsFactory.kt index 0be111cadb..f834a58d30 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetWalletNotificationsFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetWalletNotificationsFactory.kt @@ -5,6 +5,8 @@ import com.tangem.core.decompose.di.ModelScoped import com.tangem.core.ui.ds.message.TangemMessageEffect import com.tangem.core.ui.extensions.resourceReference import com.tangem.domain.account.status.producer.SingleAccountStatusListProducer +import com.tangem.domain.assetsdiscovery.model.AssetsDiscoveryProgress +import com.tangem.domain.assetsdiscovery.usecase.ObserveAssetsDiscoveryUseCase import com.tangem.domain.card.CardTypesResolver import com.tangem.domain.card.common.util.cardTypesResolver import com.tangem.domain.demo.IsDemoCardUseCase @@ -22,6 +24,7 @@ import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents import com.tangem.feature.wallet.impl.R import com.tangem.feature.wallet.presentation.account.AccountDependencies import com.tangem.feature.wallet.presentation.wallet.state.model.WalletNotificationUM +import com.tangem.features.hotwallet.HotWalletFeatureToggles import com.tangem.hot.sdk.model.HotWalletId import com.tangem.lib.crypto.BlockchainUtils import com.tangem.utils.extensions.addIf @@ -36,7 +39,7 @@ import javax.inject.Inject * Factory for creating a list of notifications that can be shown on the wallet screen. * These notifications are critical and should be shown separately from each other. */ -@Suppress("LongParameterList") +@Suppress("LongParameterList", "LargeClass") @ModelScoped internal class GetWalletNotificationsFactory @Inject constructor( private val isDemoCardUseCase: IsDemoCardUseCase, @@ -45,6 +48,8 @@ internal class GetWalletNotificationsFactory @Inject constructor( private val accountDependencies: AccountDependencies, private val getAccessCodeSkippedUseCase: GetAccessCodeSkippedUseCase, private val hasSingleWalletSignedHashesUseCase: HasSingleWalletSignedHashesUseCase, + private val observeAssetsDiscoveryUseCase: ObserveAssetsDiscoveryUseCase, + private val hotWalletFeatureToggles: HotWalletFeatureToggles, ) { fun create(userWallet: UserWallet, clickIntents: WalletClickIntents): Flow> { val cardTypesResolver = (userWallet as? UserWallet.Cold)?.scanResponse?.cardTypesResolver @@ -52,11 +57,19 @@ internal class GetWalletNotificationsFactory @Inject constructor( val params = SingleAccountStatusListProducer.Params(userWallet.walletId) val accountStatusListFlow = accountDependencies.singleAccountStatusListSupplier(params) + val assetsDiscoveryProgressFlow = + if (hotWalletFeatureToggles.isAssetsDiscoveryEnabled && userWallet is UserWallet.Hot) { + observeAssetsDiscoveryUseCase(userWallet.walletId).distinctUntilChanged() + } else { + flowOf(AssetsDiscoveryProgress.Idle) + } + return combine( flow = accountStatusListFlow, flow2 = isNeedToBackupUseCase(userWallet.walletId).distinctUntilChanged(), flow3 = getAccessCodeSkippedUseCase(userWallet.walletId).distinctUntilChanged(), - ) { accountList, isNeedToBackup, shouldAccessCodeSkipped -> + flow4 = assetsDiscoveryProgressFlow, + ) { accountList, isNeedToBackup, shouldAccessCodeSkipped, assetsDiscoveryProgress -> val totalFiatBalance = accountList.totalFiatBalance val flattenCurrencies = accountList.flattenCurrencies() @@ -101,6 +114,12 @@ internal class GetWalletNotificationsFactory @Inject constructor( clickIntents = clickIntents, ) + addAssetsDiscoveryCompletedNotification( + userWallet = userWallet, + assetsDiscoveryProgress = assetsDiscoveryProgress, + clickIntents = clickIntents, + ) + if (paymentAccountStatus != null) { addTangemPayWarnings( status = paymentAccountStatus, @@ -311,6 +330,20 @@ internal class GetWalletNotificationsFactory @Inject constructor( return any { it.value is CryptoCurrencyStatus.Unreachable } } + private fun MutableList.addAssetsDiscoveryCompletedNotification( + userWallet: UserWallet, + assetsDiscoveryProgress: AssetsDiscoveryProgress, + clickIntents: WalletClickIntents, + ) { + addIf( + element = WalletNotificationUM.AssetsDiscoveryCompleted( + onCloseClick = { clickIntents.onDismissAssetsDiscoveryNotification(userWallet.walletId) }, + onManageTokensClick = { clickIntents.onAssetsDiscoveryManageClick(userWallet.walletId) }, + ), + condition = assetsDiscoveryProgress is AssetsDiscoveryProgress.Completed, + ) + } + private fun MutableList.addFinishWalletActivationNotification( userWallet: UserWallet, totalFiatBalance: TotalFiatBalance, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletNotificationUM.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletNotificationUM.kt index 3ae343814d..e6c36a1e49 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletNotificationUM.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletNotificationUM.kt @@ -526,5 +526,30 @@ internal sealed class WalletNotificationUM(val messageUM: TangemMessageUM, val t ), type = WalletNotificationType.Informational, ) + + data class AssetsDiscoveryCompleted( + val onCloseClick: () -> Unit, + val onManageTokensClick: () -> Unit, + ) : WalletNotificationUM( + messageUM = TangemMessageUM( + id = "AssetsDiscoveryCompletedNotification", + title = resourceReference(R.string.initial_wallet_sync_banner_title), + subtitle = resourceReference(R.string.initial_wallet_sync_banner_description), + iconUM = TangemIconUM.Icon( + iconRes = R.drawable.ic_check_circle_24, + tintReference = { TangemTheme.colors2.graphic.status.accent }, + ), + messageEffect = TangemMessageEffect.None, + onCloseClick = onCloseClick, + buttonsUM = persistentListOf( + TangemMessageButtonUM( + text = resourceReference(R.string.main_manage_tokens), + onClick = onManageTokensClick, + type = TangemButtonType.Secondary, + ), + ), + ), + type = WalletNotificationType.Informational, + ) // endregion } \ No newline at end of file