Updated on 2026-08-14

This commit is contained in:
Tangem 2024-04-04 13:36:35 +05:00
parent 788a471871
commit 28b202b48d

View file

@ -21,6 +21,7 @@ import com.tangem.domain.walletmanager.utils.SdkPageConverter
import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.models.UserWallet
import com.tangem.domain.wallets.models.UserWalletId import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import timber.log.Timber
class DefaultTxHistoryRepository( class DefaultTxHistoryRepository(
private val cacheRegistry: CacheRegistry, private val cacheRegistry: CacheRegistry,
@ -82,16 +83,21 @@ class DefaultTxHistoryRepository(
pageSize: Int, pageSize: Int,
refresh: Boolean, refresh: Boolean,
): List<TxHistoryItem> { ): List<TxHistoryItem> {
cacheRegistry.invokeOnExpire( return try {
key = getTxHistoryPageKey(currency, userWalletId, Page.Initial), cacheRegistry.invokeOnExpire(
skipCache = refresh, key = getTxHistoryPageKey(currency, userWalletId, Page.Initial),
block = { fetchFixedSizeTxHistoryItems(userWalletId, currency, pageSize) }, skipCache = refresh,
) block = { fetchFixedSizeTxHistoryItems(userWalletId, currency, pageSize) },
val txs = txHistoryItemsStore.getSyncOrNull( )
key = TxHistoryItemsStore.Key(userWalletId, currency), val txs = txHistoryItemsStore.getSyncOrNull(
page = Page.Initial, key = TxHistoryItemsStore.Key(userWalletId, currency),
)?.items page = Page.Initial,
return txs ?: emptyList() )?.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 { private fun getTxHistoryPageKey(currency: CryptoCurrency, userWalletId: UserWalletId, page: Page): String {