From 7fe42372948e8025ebfe88c7b35a240453953ee0 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 22 Jun 2023 12:48:41 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../tangem/tap/common/analytics/events/Basic.kt | 2 ++ .../userWalletList/UserWalletsListManager.kt | 5 +++++ .../BiometricUserWalletsListManager.kt | 3 +++ .../RuntimeUserWalletsListManager.kt | 14 +++++++------- .../tap/features/wallet/ui/WalletViewModel.kt | 13 +++---------- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/common/analytics/events/Basic.kt b/app/src/main/java/com/tangem/tap/common/analytics/events/Basic.kt index f4ef3e133f..e5b89b30e5 100644 --- a/app/src/main/java/com/tangem/tap/common/analytics/events/Basic.kt +++ b/app/src/main/java/com/tangem/tap/common/analytics/events/Basic.kt @@ -31,12 +31,14 @@ sealed class Basic( currency: AnalyticsParam.CardCurrency, batch: String, signInType: SignInType, + walletsCount: String, ) : Basic( event = "Signed in", params = mapOf( AnalyticsParam.CURRENCY to currency.value, AnalyticsParam.BATCH to batch, "Sign in type" to signInType.name, + "Wallets Count" to walletsCount, ), ) { enum class SignInType { diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManager.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManager.kt index b1c97b594b..249ac0d0f4 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManager.kt @@ -26,6 +26,11 @@ interface UserWalletsListManager { * */ val hasUserWallets: Boolean + /** + * Count of saved user wallets + */ + val walletsCount: Int + /** * Set [UserWallet] with provided [UserWalletId] as selected * diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/BiometricUserWalletsListManager.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/BiometricUserWalletsListManager.kt index 4ea180e270..568d16fc28 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/BiometricUserWalletsListManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/BiometricUserWalletsListManager.kt @@ -53,6 +53,9 @@ internal class BiometricUserWalletsListManager( override val hasUserWallets: Boolean get() = keysRepository.hasSavedEncryptionKeys() + override val walletsCount: Int + get() = state.value.userWallets.size + override suspend fun unlock(): CompletionResult { return unlockWithBiometryInternal() .mapFailure { error -> diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/RuntimeUserWalletsListManager.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/RuntimeUserWalletsListManager.kt index c94958d46f..cfcd68bc57 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/RuntimeUserWalletsListManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/implementation/RuntimeUserWalletsListManager.kt @@ -7,13 +7,7 @@ import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.domain.userWalletList.UserWalletsListError import com.tangem.tap.domain.userWalletList.UserWalletsListManager import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.distinctUntilChanged -import kotlinx.coroutines.flow.filterNotNull -import kotlinx.coroutines.flow.mapLatest -import kotlinx.coroutines.flow.update -import kotlinx.coroutines.flow.updateAndGet +import kotlinx.coroutines.flow.* @OptIn(ExperimentalCoroutinesApi::class) internal class RuntimeUserWalletsListManager : UserWalletsListManager { @@ -36,6 +30,12 @@ internal class RuntimeUserWalletsListManager : UserWalletsListManager { override val hasUserWallets: Boolean get() = state.value.userWallet != null + /** + * only 1 wallet stored in runtime implementation + */ + override val walletsCount: Int + get() = 1 + override suspend fun select(userWalletId: UserWalletId): CompletionResult = catching { state.value.userWallet ?.takeIf { it.walletId == userWalletId } diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletViewModel.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletViewModel.kt index ded1be23f3..95f80ebca8 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletViewModel.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletViewModel.kt @@ -17,16 +17,8 @@ import com.tangem.tap.features.wallet.ui.analytics.WalletAnalyticsEventsMapper import com.tangem.tap.store import com.tangem.tap.walletStoresManager import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.FlowPreview -import kotlinx.coroutines.Job -import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.debounce -import kotlinx.coroutines.flow.flatMapLatest -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.launch +import kotlinx.coroutines.* +import kotlinx.coroutines.flow.* import org.rekotlin.StoreSubscriber import javax.inject.Inject @@ -71,6 +63,7 @@ internal class WalletViewModel @Inject constructor( currency = currency, batch = scanResponse.card.batchId, signInType = signInType, + walletsCount = store.state.globalState.userWalletsListManager?.walletsCount.toString(), ), ) }