Updated on 2026-08-14
This commit is contained in:
parent
72a1365157
commit
f4ab3116fe
6 changed files with 27 additions and 39 deletions
|
|
@ -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 */
|
||||
}
|
||||
}
|
||||
|
|
@ -8,4 +8,6 @@ interface SelectedAppCurrencyStore {
|
|||
fun get(): Flow<CurrenciesResponse.Currency>
|
||||
|
||||
suspend fun store(item: CurrenciesResponse.Currency)
|
||||
|
||||
suspend fun isEmpty(): Boolean
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue