Updated on 2026-08-14

This commit is contained in:
Tangem 2023-08-16 16:53:42 +03:00
parent 72a1365157
commit f4ab3116fe
6 changed files with 27 additions and 39 deletions

View file

@ -1,26 +0,0 @@
package com.tangem.datasource.local.appcurrency
import com.tangem.datasource.api.tangemTech.models.CurrenciesResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
// TODO: Will be implemented in [REDACTED_TASK_KEY] task
internal class MockSelectedAppCurrencyStore : SelectedAppCurrencyStore {
override fun get(): Flow<CurrenciesResponse.Currency> {
return flowOf(
CurrenciesResponse.Currency(
id = "usd",
code = "USD",
name = "US Dollar",
unit = "$",
type = "fiat",
rateBTC = "",
),
)
}
override suspend fun store(item: CurrenciesResponse.Currency) {
/* no-op */
}
}

View file

@ -8,4 +8,6 @@ interface SelectedAppCurrencyStore {
fun get(): Flow<CurrenciesResponse.Currency>
suspend fun store(item: CurrenciesResponse.Currency)
suspend fun isEmpty(): Boolean
}

View file

@ -7,4 +7,9 @@ import com.tangem.datasource.local.datastore.core.StringKeyDataStore
internal class DefaultSelectedAppCurrencyStore(
dataStore: StringKeyDataStore<CurrenciesResponse.Currency>,
) : SelectedAppCurrencyStore, KeylessDataStoreDecorator<CurrenciesResponse.Currency>(dataStore)
) : SelectedAppCurrencyStore, KeylessDataStoreDecorator<CurrenciesResponse.Currency>(dataStore) {
override suspend fun isEmpty(): Boolean {
return getSyncOrNull() == null
}
}

View file

@ -10,15 +10,15 @@ internal abstract class KeylessDataStoreDecorator<Value : Any>(
return STRING_KEY
}
fun get(): Flow<Value> {
open fun get(): Flow<Value> {
return get(Unit)
}
suspend fun getSyncOrNull(): Value? {
open suspend fun getSyncOrNull(): Value? {
return getSyncOrNull(Unit)
}
suspend fun store(item: Value) {
open suspend fun store(item: Value) {
store(Unit, item)
}