Updated on 2026-08-14
This commit is contained in:
parent
494aa88d35
commit
aa059666ba
10 changed files with 96 additions and 51 deletions
|
|
@ -6,6 +6,8 @@ import com.tangem.datasource.local.preferences.AppPreferencesStore
|
|||
import com.tangem.datasource.local.preferences.PreferencesKeys
|
||||
import com.tangem.datasource.local.preferences.utils.getObjectList
|
||||
import com.tangem.datasource.local.preferences.utils.getObjectListSync
|
||||
import com.tangem.datasource.local.preferences.utils.getSyncOrDefault
|
||||
import com.tangem.datasource.local.preferences.utils.store
|
||||
import com.tangem.domain.card.repository.CardRepository
|
||||
import com.tangem.utils.extensions.addOrReplace
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
|
@ -64,6 +66,28 @@ internal class DefaultCardRepository(
|
|||
return card.isActivationStarted && !card.isActivationFinished
|
||||
}
|
||||
|
||||
override suspend fun isTangemTOSAccepted(): Boolean {
|
||||
return appPreferencesStore.getSyncOrDefault(key = PreferencesKeys.IS_TANGEM_TOS_ACCEPTED_KEY, default = false)
|
||||
}
|
||||
|
||||
override suspend fun isStart2CoinTOSAccepted(cardId: String): Boolean {
|
||||
return appPreferencesStore.getSyncOrDefault(
|
||||
key = PreferencesKeys.getStart2CoinTOSAcceptedKey(region = getRegion(cardId)),
|
||||
default = false,
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun acceptTangemTOS() {
|
||||
return appPreferencesStore.store(key = PreferencesKeys.IS_TANGEM_TOS_ACCEPTED_KEY, true)
|
||||
}
|
||||
|
||||
override suspend fun acceptStart2CoinTOS(cardId: String) {
|
||||
appPreferencesStore.store(
|
||||
key = PreferencesKeys.getStart2CoinTOSAcceptedKey(region = getRegion(cardId)),
|
||||
value = true,
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun AppPreferencesStore.editUsedCards(cardId: String, update: (UsedCardInfo) -> UsedCardInfo) {
|
||||
editData { mutablePreferences ->
|
||||
val usedCards = mutablePreferences.getUsedCards()
|
||||
|
|
@ -92,4 +116,15 @@ internal class DefaultCardRepository(
|
|||
return appPreferencesStore.getObjectListSync<UsedCardInfo>(PreferencesKeys.USED_CARDS_INFO_KEY)
|
||||
.firstOrNull { it.cardId == cardId }
|
||||
}
|
||||
|
||||
private fun getRegion(cardId: String): String? {
|
||||
if (cardId.isEmpty()) return null
|
||||
|
||||
return when (cardId[1]) {
|
||||
'0' -> "fr"
|
||||
'1' -> "ch"
|
||||
'2' -> "at"
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue