From 28b202b48dea4265db272a111d913ee2b402df3c Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 4 Apr 2024 13:36:35 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../repository/DefaultTxHistoryRepository.kt | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt b/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt index 9f4801ff8c..dba0ed594a 100644 --- a/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt +++ b/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt @@ -21,6 +21,7 @@ import com.tangem.domain.walletmanager.utils.SdkPageConverter import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.models.UserWalletId import kotlinx.coroutines.flow.Flow +import timber.log.Timber class DefaultTxHistoryRepository( private val cacheRegistry: CacheRegistry, @@ -82,16 +83,21 @@ class DefaultTxHistoryRepository( pageSize: Int, refresh: Boolean, ): List { - cacheRegistry.invokeOnExpire( - key = getTxHistoryPageKey(currency, userWalletId, Page.Initial), - skipCache = refresh, - block = { fetchFixedSizeTxHistoryItems(userWalletId, currency, pageSize) }, - ) - val txs = txHistoryItemsStore.getSyncOrNull( - key = TxHistoryItemsStore.Key(userWalletId, currency), - page = Page.Initial, - )?.items - return txs ?: emptyList() + return try { + cacheRegistry.invokeOnExpire( + key = getTxHistoryPageKey(currency, userWalletId, Page.Initial), + skipCache = refresh, + block = { fetchFixedSizeTxHistoryItems(userWalletId, currency, pageSize) }, + ) + val txs = txHistoryItemsStore.getSyncOrNull( + key = TxHistoryItemsStore.Key(userWalletId, currency), + page = Page.Initial, + )?.items + txs ?: emptyList() + } catch (e: Throwable) { + Timber.e(e, "Unable to load the transaction history for the requested page: ${Page.Initial}") + emptyList() + } } private fun getTxHistoryPageKey(currency: CryptoCurrency, userWalletId: UserWalletId, page: Page): String {