Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-16 16:27:26 +05:00
parent 2ed66a5049
commit dc9de9265c
3 changed files with 61 additions and 2 deletions

View file

@ -144,6 +144,7 @@ internal class WalletWarningsAnalyticsSender @Inject constructor(
is WalletNotificationUM.TangemPayRefreshNeeded,
WalletNotificationUM.TangemPayUnreachable,
is WalletNotificationUM.YieldBoostPromo,
is WalletNotificationUM.AssetsDiscoveryCompleted,
-> null
}
}

View file

@ -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<ImmutableList<WalletNotificationUM>> {
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<WalletNotificationUM>.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<WalletNotificationUM>.addFinishWalletActivationNotification(
userWallet: UserWallet,
totalFiatBalance: TotalFiatBalance,

View file

@ -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
}