Updated on 2026-08-14

This commit is contained in:
Tangem 2026-02-25 16:38:32 +05:00
parent 6e2ad61589
commit 84153dd63b
7 changed files with 52 additions and 21 deletions

View file

@ -3,6 +3,7 @@ package com.tangem.tap.di.domain
import com.tangem.domain.hotwallet.CheckHotWalletUpgradeBannerUseCase import com.tangem.domain.hotwallet.CheckHotWalletUpgradeBannerUseCase
import com.tangem.domain.hotwallet.CloseHotWalletUpgradeBannerUseCase import com.tangem.domain.hotwallet.CloseHotWalletUpgradeBannerUseCase
import com.tangem.domain.hotwallet.GetAccessCodeSkippedUseCase import com.tangem.domain.hotwallet.GetAccessCodeSkippedUseCase
import com.tangem.domain.hotwallet.GetUpgradeBannerClosureTimestampUseCase
import com.tangem.domain.hotwallet.IsHotWalletCreationSupported import com.tangem.domain.hotwallet.IsHotWalletCreationSupported
import com.tangem.domain.hotwallet.IsAccessCodeSimpleUseCase import com.tangem.domain.hotwallet.IsAccessCodeSimpleUseCase
import com.tangem.domain.hotwallet.SetAccessCodeSkippedUseCase import com.tangem.domain.hotwallet.SetAccessCodeSkippedUseCase
@ -67,4 +68,12 @@ internal object HotWalletDomainModule {
): ShouldShowUpgradeHotWalletBannerUseCase { ): ShouldShowUpgradeHotWalletBannerUseCase {
return ShouldShowUpgradeHotWalletBannerUseCase(hotWalletRepository) return ShouldShowUpgradeHotWalletBannerUseCase(hotWalletRepository)
} }
@Provides
@Singleton
fun provideGetUpgradeBannerClosureTimestampUseCase(
hotWalletRepository: HotWalletRepository,
): GetUpgradeBannerClosureTimestampUseCase {
return GetUpgradeBannerClosureTimestampUseCase(hotWalletRepository)
}
} }

View file

@ -53,10 +53,9 @@ internal class DefaultHotWalletRepository(
} }
} }
override suspend fun getUpgradeBannerClosureTimestamp(userWalletId: UserWalletId): Long? { override fun upgradeBannerClosureTimestamp(userWalletId: UserWalletId): Flow<Long?> = appPreferencesStore
return appPreferencesStore .getObjectMap<Long>(PreferencesKeys.UPGRADE_BANNER_CLOSURE_TIMESTAMP_KEY)
.getObjectMapSync<Long>(PreferencesKeys.UPGRADE_BANNER_CLOSURE_TIMESTAMP_KEY)[userWalletId.stringValue] .map { it[userWalletId.stringValue] }
}
override suspend fun setUpgradeBannerClosureTimestamp(userWalletId: UserWalletId, timestamp: Long?) { override suspend fun setUpgradeBannerClosureTimestamp(userWalletId: UserWalletId, timestamp: Long?) {
appPreferencesStore.editData { mutablePreferences -> appPreferencesStore.editData { mutablePreferences ->

View file

@ -14,6 +14,7 @@ class CheckHotWalletUpgradeBannerUseCase(
walletId: UserWalletId, walletId: UserWalletId,
hasBalance: Boolean, hasBalance: Boolean,
shouldShowUpgradeBanner: Boolean, shouldShowUpgradeBanner: Boolean,
closureTimestamp: Long?,
): Either<Throwable, Boolean> = try { ): Either<Throwable, Boolean> = try {
val currentTime = System.currentTimeMillis() val currentTime = System.currentTimeMillis()
val creationTimestamp = hotWalletRepository.getWalletCreationTimestamp(walletId) val creationTimestamp = hotWalletRepository.getWalletCreationTimestamp(walletId)
@ -27,7 +28,6 @@ class CheckHotWalletUpgradeBannerUseCase(
creationTimestamp creationTimestamp
} }
val closureTimestamp = hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId)
val hasHadFirstTopUp = hotWalletRepository.hasHadFirstTopUp(walletId) val hasHadFirstTopUp = hotWalletRepository.hasHadFirstTopUp(walletId)
val daysSinceCreation = TimeUnit.MILLISECONDS.toDays(currentTime - creationTimestampActual) val daysSinceCreation = TimeUnit.MILLISECONDS.toDays(currentTime - creationTimestampActual)

View file

@ -0,0 +1,13 @@
package com.tangem.domain.hotwallet
import com.tangem.domain.hotwallet.repository.HotWalletRepository
import com.tangem.domain.models.wallet.UserWalletId
import kotlinx.coroutines.flow.Flow
class GetUpgradeBannerClosureTimestampUseCase(
private val hotWalletRepository: HotWalletRepository,
) {
operator fun invoke(userWalletId: UserWalletId): Flow<Long?> {
return hotWalletRepository.upgradeBannerClosureTimestamp(userWalletId)
}
}

View file

@ -17,7 +17,7 @@ interface HotWalletRepository {
suspend fun setShouldShowUpgradeBanner(userWalletId: UserWalletId, shouldShow: Boolean) suspend fun setShouldShowUpgradeBanner(userWalletId: UserWalletId, shouldShow: Boolean)
suspend fun getUpgradeBannerClosureTimestamp(userWalletId: UserWalletId): Long? fun upgradeBannerClosureTimestamp(userWalletId: UserWalletId): Flow<Long?>
suspend fun setUpgradeBannerClosureTimestamp(userWalletId: UserWalletId, timestamp: Long?) suspend fun setUpgradeBannerClosureTimestamp(userWalletId: UserWalletId, timestamp: Long?)

View file

@ -23,7 +23,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
@Test @Test
fun `GIVEN creation timestamp is null WHEN invoke THEN set timestamp and return false`() = runTest { fun `GIVEN creation timestamp is null WHEN invoke THEN set timestamp and return false`() = runTest {
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns null coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns null
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns null
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false
@ -31,6 +30,7 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = false, hasBalance = false,
shouldShowUpgradeBanner = false, shouldShowUpgradeBanner = false,
closureTimestamp = null,
) )
assertThat(result).isInstanceOf(Either.Right::class.java) assertThat(result).isInstanceOf(Either.Right::class.java)
@ -42,7 +42,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
fun `GIVEN shouldShowUpgradeBanner is true and hasBalance WHEN invoke THEN return true`() = runTest { fun `GIVEN shouldShowUpgradeBanner is true and hasBalance WHEN invoke THEN return true`() = runTest {
val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5) val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5)
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns null
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false
@ -50,6 +49,7 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = true, hasBalance = true,
shouldShowUpgradeBanner = true, shouldShowUpgradeBanner = true,
closureTimestamp = null,
) )
assertThat(result).isInstanceOf(Either.Right::class.java) assertThat(result).isInstanceOf(Either.Right::class.java)
@ -60,7 +60,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
fun `GIVEN shouldShowUpgradeBanner is true WHEN invoke THEN return true regardless of balance`() = runTest { fun `GIVEN shouldShowUpgradeBanner is true WHEN invoke THEN return true regardless of balance`() = runTest {
val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5) val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5)
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns null
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false
@ -68,6 +67,7 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = false, hasBalance = false,
shouldShowUpgradeBanner = true, shouldShowUpgradeBanner = true,
closureTimestamp = null,
) )
assertThat(result).isInstanceOf(Either.Right::class.java) assertThat(result).isInstanceOf(Either.Right::class.java)
@ -79,7 +79,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60) val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60)
val closureTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(31) val closureTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(31)
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns closureTimestamp
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false
@ -87,6 +86,7 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = true, hasBalance = true,
shouldShowUpgradeBanner = false, shouldShowUpgradeBanner = false,
closureTimestamp = closureTimestamp,
) )
assertThat(result).isInstanceOf(Either.Right::class.java) assertThat(result).isInstanceOf(Either.Right::class.java)
@ -99,7 +99,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60) val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60)
val closureTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(15) val closureTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(15)
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns closureTimestamp
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false
@ -107,7 +106,8 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = true, hasBalance = true,
shouldShowUpgradeBanner = false, shouldShowUpgradeBanner = false,
) closureTimestamp = closureTimestamp,
)
assertThat(result).isInstanceOf(Either.Right::class.java) assertThat(result).isInstanceOf(Either.Right::class.java)
assertThat((result as Either.Right).value).isFalse() assertThat((result as Either.Right).value).isFalse()
@ -117,7 +117,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
fun `GIVEN no flags set and no closure and 30 days since creation WHEN invoke THEN return true`() = runTest { fun `GIVEN no flags set and no closure and 30 days since creation WHEN invoke THEN return true`() = runTest {
val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(31) val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(31)
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns null
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false
@ -125,6 +124,7 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = false, hasBalance = false,
shouldShowUpgradeBanner = false, shouldShowUpgradeBanner = false,
closureTimestamp = null,
) )
assertThat(result).isInstanceOf(Either.Right::class.java) assertThat(result).isInstanceOf(Either.Right::class.java)
@ -135,7 +135,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
fun `GIVEN no flags set but less than 30 days since creation WHEN invoke THEN return false`() = runTest { fun `GIVEN no flags set but less than 30 days since creation WHEN invoke THEN return false`() = runTest {
val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(15) val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(15)
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns null
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false
@ -143,6 +142,7 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = false, hasBalance = false,
shouldShowUpgradeBanner = false, shouldShowUpgradeBanner = false,
closureTimestamp = null,
) )
assertThat(result).isInstanceOf(Either.Right::class.java) assertThat(result).isInstanceOf(Either.Right::class.java)
@ -154,7 +154,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60) val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(60)
val closureTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5) val closureTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5)
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns closureTimestamp
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false
@ -162,6 +161,7 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = false, hasBalance = false,
shouldShowUpgradeBanner = false, shouldShowUpgradeBanner = false,
closureTimestamp = closureTimestamp,
) )
assertThat(result).isInstanceOf(Either.Right::class.java) assertThat(result).isInstanceOf(Either.Right::class.java)
@ -172,7 +172,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
fun `GIVEN first top-up detected WHEN invoke THEN return false and mark session`() = runTest { fun `GIVEN first top-up detected WHEN invoke THEN return false and mark session`() = runTest {
val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5) val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5)
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns null
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false
@ -180,6 +179,7 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = true, hasBalance = true,
shouldShowUpgradeBanner = false, shouldShowUpgradeBanner = false,
closureTimestamp = null,
) )
assertThat(result).isInstanceOf(Either.Right::class.java) assertThat(result).isInstanceOf(Either.Right::class.java)
@ -194,7 +194,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
fun `GIVEN first top-up detected this session WHEN invoke THEN return false`() = runTest { fun `GIVEN first top-up detected this session WHEN invoke THEN return false`() = runTest {
val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5) val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5)
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns null
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns true every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns true
@ -202,6 +201,7 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = true, hasBalance = true,
shouldShowUpgradeBanner = true, shouldShowUpgradeBanner = true,
closureTimestamp = null,
) )
assertThat(result).isInstanceOf(Either.Right::class.java) assertThat(result).isInstanceOf(Either.Right::class.java)
@ -212,7 +212,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
fun `GIVEN already had first top-up WHEN invoke with balance THEN do not set flags again`() = runTest { fun `GIVEN already had first top-up WHEN invoke with balance THEN do not set flags again`() = runTest {
val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5) val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5)
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns null
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns true
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false
@ -220,6 +219,7 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = true, hasBalance = true,
shouldShowUpgradeBanner = true, shouldShowUpgradeBanner = true,
closureTimestamp = null,
) )
coVerify(exactly = 0) { hotWalletRepository.setHasHadFirstTopUp(any(), any()) } coVerify(exactly = 0) { hotWalletRepository.setHasHadFirstTopUp(any(), any()) }
@ -230,7 +230,6 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
fun `GIVEN multiple re-emissions with same state WHEN invoke THEN return same result`() = runTest { fun `GIVEN multiple re-emissions with same state WHEN invoke THEN return same result`() = runTest {
val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(31) val creationTimestamp = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(31)
coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp coEvery { hotWalletRepository.getWalletCreationTimestamp(walletId) } returns creationTimestamp
coEvery { hotWalletRepository.getUpgradeBannerClosureTimestamp(walletId) } returns null
coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false coEvery { hotWalletRepository.hasHadFirstTopUp(walletId) } returns false
every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false every { hotWalletRepository.isFirstTopUpDetectedThisSession(walletId) } returns false
@ -238,16 +237,19 @@ class CheckHotWalletUpgradeBannerUseCaseTest {
walletId = walletId, walletId = walletId,
hasBalance = false, hasBalance = false,
shouldShowUpgradeBanner = false, shouldShowUpgradeBanner = false,
closureTimestamp = null,
) )
val result2 = useCase( val result2 = useCase(
walletId = walletId, walletId = walletId,
hasBalance = false, hasBalance = false,
shouldShowUpgradeBanner = false, shouldShowUpgradeBanner = false,
closureTimestamp = null,
) )
val result3 = useCase( val result3 = useCase(
walletId = walletId, walletId = walletId,
hasBalance = false, hasBalance = false,
shouldShowUpgradeBanner = false, shouldShowUpgradeBanner = false,
closureTimestamp = null,
) )
assertThat((result1 as Either.Right).value).isTrue() assertThat((result1 as Either.Right).value).isTrue()

View file

@ -15,6 +15,7 @@ import com.tangem.domain.core.lce.LceFlow
import com.tangem.domain.demo.IsDemoCardUseCase import com.tangem.domain.demo.IsDemoCardUseCase
import com.tangem.domain.hotwallet.CheckHotWalletUpgradeBannerUseCase import com.tangem.domain.hotwallet.CheckHotWalletUpgradeBannerUseCase
import com.tangem.domain.hotwallet.GetAccessCodeSkippedUseCase import com.tangem.domain.hotwallet.GetAccessCodeSkippedUseCase
import com.tangem.domain.hotwallet.GetUpgradeBannerClosureTimestampUseCase
import com.tangem.domain.hotwallet.ShouldShowUpgradeHotWalletBannerUseCase import com.tangem.domain.hotwallet.ShouldShowUpgradeHotWalletBannerUseCase
import com.tangem.domain.models.StatusSource import com.tangem.domain.models.StatusSource
import com.tangem.domain.models.TotalFiatBalance import com.tangem.domain.models.TotalFiatBalance
@ -62,10 +63,11 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
private val accountDependencies: AccountDependencies, private val accountDependencies: AccountDependencies,
private val getAccessCodeSkippedUseCase: GetAccessCodeSkippedUseCase, private val getAccessCodeSkippedUseCase: GetAccessCodeSkippedUseCase,
private val shouldShowUpgradeHotWalletBannerUseCase: ShouldShowUpgradeHotWalletBannerUseCase, private val shouldShowUpgradeHotWalletBannerUseCase: ShouldShowUpgradeHotWalletBannerUseCase,
private val getUpgradeBannerClosureTimestampUseCase: GetUpgradeBannerClosureTimestampUseCase,
private val checkHotWalletUpgradeBannerUseCase: CheckHotWalletUpgradeBannerUseCase, private val checkHotWalletUpgradeBannerUseCase: CheckHotWalletUpgradeBannerUseCase,
) { ) {
@Suppress("UNCHECKED_CAST", "MagicNumber", "LongMethod") @Suppress("UNCHECKED_CAST", "MagicNumber", "LongMethod", "CastNullableToNonNullableType")
fun create(userWallet: UserWallet, clickIntents: WalletClickIntents): Flow<ImmutableList<WalletNotification>> { fun create(userWallet: UserWallet, clickIntents: WalletClickIntents): Flow<ImmutableList<WalletNotification>> {
val cardTypesResolver = (userWallet as? UserWallet.Cold)?.scanResponse?.cardTypesResolver val cardTypesResolver = (userWallet as? UserWallet.Cold)?.scanResponse?.cardTypesResolver
@ -105,8 +107,10 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
.distinctUntilChanged(), .distinctUntilChanged(),
shouldShowUpgradeHotWalletBannerUseCase.invoke(userWallet.walletId) shouldShowUpgradeHotWalletBannerUseCase.invoke(userWallet.walletId)
.distinctUntilChanged(), .distinctUntilChanged(),
getUpgradeBannerClosureTimestampUseCase(userWallet.walletId)
.distinctUntilChanged(),
) { array -> array } ) { array -> array }
.combine(tokenListFlow()) { array, any: Any -> arrayOf(any).plus(elements = array) } .combine(tokenListFlow()) { array, any: Any? -> arrayOf(any).plus(elements = array) }
.map { array -> .map { array ->
val lceTokens = array[0] as Lce<TokenListError, Pair<TotalFiatBalance, List<CryptoCurrencyStatus>>> val lceTokens = array[0] as Lce<TokenListError, Pair<TotalFiatBalance, List<CryptoCurrencyStatus>>>
val totalFiatBalance = lceTokens.map { it.first } val totalFiatBalance = lceTokens.map { it.first }
@ -119,6 +123,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
val shouldAccessCodeSkipped = array[6] as Boolean val shouldAccessCodeSkipped = array[6] as Boolean
val shouldShowYieldPromo = array[7] as Boolean val shouldShowYieldPromo = array[7] as Boolean
val shouldShowUpgradeBanner = array[8] as Boolean val shouldShowUpgradeBanner = array[8] as Boolean
val closureTimestamp = array[9] as? Long
buildList { buildList {
addUsedOutdatedDataNotification(totalFiatBalance) addUsedOutdatedDataNotification(totalFiatBalance)
@ -130,6 +135,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
flattenCurrencies = flattenCurrencies, flattenCurrencies = flattenCurrencies,
clickIntents = clickIntents, clickIntents = clickIntents,
shouldShowUpgradeBanner = shouldShowUpgradeBanner, shouldShowUpgradeBanner = shouldShowUpgradeBanner,
closureTimestamp = closureTimestamp,
) )
addFinishWalletActivationNotification( addFinishWalletActivationNotification(
@ -469,6 +475,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
flattenCurrencies: Lce<TokenListError, List<CryptoCurrencyStatus>>, flattenCurrencies: Lce<TokenListError, List<CryptoCurrencyStatus>>,
clickIntents: WalletClickIntents, clickIntents: WalletClickIntents,
shouldShowUpgradeBanner: Boolean, shouldShowUpgradeBanner: Boolean,
closureTimestamp: Long?,
) { ) {
if (userWallet !is UserWallet.Hot) return if (userWallet !is UserWallet.Hot) return
@ -479,6 +486,7 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
walletId = userWallet.walletId, walletId = userWallet.walletId,
hasBalance = hasBalance, hasBalance = hasBalance,
shouldShowUpgradeBanner = shouldShowUpgradeBanner, shouldShowUpgradeBanner = shouldShowUpgradeBanner,
closureTimestamp = closureTimestamp,
).getOrNull() ?: return ).getOrNull() ?: return
addIf( addIf(