Updated on 2026-08-14
This commit is contained in:
parent
f3f29813e0
commit
b74e2b9168
25 changed files with 405 additions and 72 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.data.appcurrency
|
||||
|
||||
import com.tangem.data.appcurrency.utils.AppCurrencyConverter
|
||||
import com.tangem.data.common.api.safeApiCall
|
||||
import com.tangem.data.common.cache.CacheRegistry
|
||||
import com.tangem.datasource.api.tangemTech.TangemTechApi
|
||||
import com.tangem.datasource.api.tangemTech.models.CurrenciesResponse
|
||||
|
|
@ -15,7 +16,6 @@ import kotlinx.coroutines.flow.map
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.joda.time.Duration
|
||||
import timber.log.Timber
|
||||
|
||||
internal class DefaultAppCurrencyRepository(
|
||||
private val tangemTechApi: TangemTechApi,
|
||||
|
|
@ -80,17 +80,15 @@ internal class DefaultAppCurrencyRepository(
|
|||
}
|
||||
|
||||
private suspend fun fetchAvailableCurrencies() {
|
||||
try {
|
||||
val response = tangemTechApi.getCurrencyList()
|
||||
val response = safeApiCall(
|
||||
call = { tangemTechApi.getCurrencyList().bind() },
|
||||
onError = {
|
||||
cacheRegistry.invalidate(AVAILABLE_CURRENCIES_CACHE_KEY)
|
||||
getDefaultCurrenciesResponse()
|
||||
},
|
||||
)
|
||||
|
||||
availableAppCurrenciesStore.store(response)
|
||||
} catch (e: Throwable) {
|
||||
Timber.e(e, "Unable to fetch available currencies")
|
||||
|
||||
availableAppCurrenciesStore.store(getDefaultCurrenciesResponse())
|
||||
|
||||
throw e
|
||||
}
|
||||
availableAppCurrenciesStore.store(response)
|
||||
}
|
||||
|
||||
private fun getDefaultCurrenciesResponse(): CurrenciesResponse = CurrenciesResponse(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue