Updated on 2026-08-14

This commit is contained in:
Tangem 2024-10-07 15:32:56 +04:00
parent 3993e1d690
commit bb58d027c6
19 changed files with 200 additions and 19 deletions

View file

@ -17,6 +17,7 @@ dependencies {
implementation(projects.domain.balanceHiding.models)
implementation(projects.domain.settings)
implementation(projects.domain.wallets.models)
implementation(deps.androidx.datastore)

View file

@ -1,13 +1,18 @@
package com.tangem.data.settings
import com.tangem.datasource.local.preferences.AppPreferencesStore
import com.tangem.datasource.local.preferences.PreferencesKeys.ADDED_WALLETS_WITH_RING_KEY
import com.tangem.datasource.local.preferences.PreferencesKeys.IS_TOKEN_SWAP_PROMO_OKX_SHOW_KEY
import com.tangem.datasource.local.preferences.PreferencesKeys.IS_WALLET_SWAP_PROMO_OKX_SHOW_KEY
import com.tangem.datasource.local.preferences.PreferencesKeys.IS_WALLET_TRAVALA_PROMO_SHOWN_KEY
import com.tangem.datasource.local.preferences.PreferencesKeys.SHOULD_SHOW_RING_PROMO_KEY
import com.tangem.datasource.local.preferences.utils.get
import com.tangem.datasource.local.preferences.utils.store
import com.tangem.domain.settings.repositories.PromoSettingsRepository
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.map
/**
* Repository for showing swap promo notification.
@ -47,4 +52,18 @@ class DefaultPromoSettingsRepository(
value = false,
)
}
override fun isReadyToShowRingPromo(userWalletId: UserWalletId): Flow<Boolean> {
return combine(
flow = appPreferencesStore
.get(key = ADDED_WALLETS_WITH_RING_KEY, default = emptySet())
.map { userWalletId.stringValue in it },
flow2 = appPreferencesStore.get(key = SHOULD_SHOW_RING_PROMO_KEY, default = true),
transform = { isRingAdded, shouldShowRingPromo -> isRingAdded && shouldShowRingPromo },
)
}
override suspend fun setNeverToShowRingPromo() {
appPreferencesStore.store(key = SHOULD_SHOW_RING_PROMO_KEY, value = false)
}
}