Updated on 2026-08-14

This commit is contained in:
Tangem 2023-10-17 23:11:05 +04:00
parent 2985a541f1
commit 6ef29ad028
3 changed files with 16 additions and 17 deletions

View file

@ -190,7 +190,8 @@ internal class DefaultCurrenciesRepository(
withContext(dispatchers.io) {
fetchTokensIfCacheExpired(userWallet, refresh = false)
}
}.cancellable()
}
.cancellable()
}
override suspend fun getMultiCurrencyWalletCurrenciesSync(

View file

@ -49,7 +49,8 @@ internal class DefaultNetworksRepository(
withContext(dispatchers.io) {
fetchNetworksStatusesIfCacheExpired(userWalletId, networks, false)
}
}.cancellable()
}
.cancellable()
override suspend fun fetchNetworkPendingTransactions(userWalletId: UserWalletId, networks: Set<Network>) {
withContext(dispatchers.io) {

View file

@ -10,8 +10,8 @@ import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.Quote
import com.tangem.domain.tokens.repository.QuotesRepository
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
internal class DefaultQuotesRepository(
@ -27,21 +27,18 @@ internal class DefaultQuotesRepository(
@Volatile
private var quotesFetchedForAppCurrency: String? = null
override fun getQuotesUpdates(currenciesIds: Set<CryptoCurrency.ID>): Flow<Set<Quote>> = channelFlow {
launch(dispatchers.io) {
quotesStore.get(currenciesIds)
.map(quotesConverter::convertSet)
.collectLatest(::send)
}
@OptIn(ExperimentalCoroutinesApi::class)
override fun getQuotesUpdates(currenciesIds: Set<CryptoCurrency.ID>): Flow<Set<Quote>> {
return selectedAppCurrencyStore.get()
.distinctUntilChanged()
.flatMapLatest { appCurrency ->
fetchExpiredQuotes(currenciesIds, appCurrency.id, refresh = false)
withContext(dispatchers.io) {
selectedAppCurrencyStore.get()
.distinctUntilChanged()
.collectLatest { appCurrency ->
fetchExpiredQuotes(currenciesIds, appCurrency.id, refresh = false)
}
}
}.cancellable()
quotesStore.get(currenciesIds).map(quotesConverter::convertSet)
}
.cancellable()
.flowOn(dispatchers.io)
}
override suspend fun getQuotesSync(currenciesIds: Set<CryptoCurrency.ID>, refresh: Boolean): Set<Quote> {
return withContext(dispatchers.io) {