Updated on 2026-08-14

This commit is contained in:
Tangem 2022-10-24 21:33:35 +05:00
commit 69cfd56c13
3 changed files with 26 additions and 9 deletions

View file

@ -26,10 +26,11 @@ class UserTokensRepository(
private val networkService: UserTokensNetworkService,
) {
suspend fun getUserTokens(card: Card): List<Currency> {
if (DemoHelper.isDemoCardId(card.cardId)) {
return loadDemoCurrencies()
}
val userId = card.getUserId()
if (DemoHelper.isDemoCardId(card.cardId)) {
return loadTokensOffline(card, userId).ifEmpty { loadDemoCurrencies() }
}
if (!NetworkConnectivity.getInstance().isOnlineOrConnecting()) {
return loadTokensOffline(card, userId)
}
@ -68,9 +69,15 @@ class UserTokensRepository(
}
suspend fun loadBlockchainsToDerive(card: Card): List<BlockchainNetwork> {
return storageService.getUserTokens(card.getUserId())?.toBlockchainNetworks() ?: storageService.getUserTokens(
card,
).toBlockchainNetworks()
val userId = card.getUserId()
val blockchainNetworks = loadTokensOffline(card, userId).toBlockchainNetworks()
if (DemoHelper.isDemoCardId(card.cardId)) {
return blockchainNetworks
.ifEmpty { loadDemoCurrencies().toBlockchainNetworks() }
}
return blockchainNetworks
}
private fun loadDemoCurrencies(): List<Currency> {