From 3ef300ee56e0c6fd5cd59b8d4f1d6f39b6eefea5 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 26 Sep 2023 14:56:05 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../transactions/TransactionList.kt | 42 ++++++++----------- .../repository/DefaultTxHistoryRepository.kt | 1 + .../usecase/GetTxHistoryItemsUseCase.kt | 2 +- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt index f28a081419..323cb0e77b 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/transactions/TransactionList.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyListScope -import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.ui.Modifier import androidx.paging.compose.LazyPagingItems import androidx.paging.compose.itemContentType @@ -57,36 +56,29 @@ private fun LazyListScope.contentItems( txHistoryItems: LazyPagingItems, modifier: Modifier = Modifier, ) { - txHistoryItems.itemKey { item -> - when (item) { - is TxHistoryState.TxHistoryItemState.GroupTitle -> item.title - is TxHistoryState.TxHistoryItemState.Title -> item.onExploreClick.hashCode() - is TxHistoryState.TxHistoryItemState.Transaction -> item.state.txHash - } - } - - txHistoryItems.itemContentType { it::class.java } - - itemsIndexed( - items = txHistoryItems.itemSnapshotList.items, - key = { _, item -> + items( + count = txHistoryItems.itemCount, + key = txHistoryItems.itemKey { item -> when (item) { is TxHistoryState.TxHistoryItemState.GroupTitle -> item.title is TxHistoryState.TxHistoryItemState.Title -> item.onExploreClick.hashCode() is TxHistoryState.TxHistoryItemState.Transaction -> item.state.txHash } }, - ) { index, item -> - TxHistoryListItem( - state = item, - modifier = modifier - .animateItemPlacement() - .roundedShapeItemDecoration( - currentIndex = index, - lastIndex = txHistoryItems.itemSnapshotList.lastIndex, - ), - ) - } + contentType = txHistoryItems.itemContentType { it::class.java }, + itemContent = { index -> + val item = txHistoryItems[index]!! + TxHistoryListItem( + state = item, + modifier = modifier + .animateItemPlacement() + .roundedShapeItemDecoration( + currentIndex = index, + lastIndex = txHistoryItems.itemSnapshotList.lastIndex, + ), + ) + }, + ) } @OptIn(ExperimentalFoundationApi::class) 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 718cfe7037..2f9fa852c0 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 @@ -39,6 +39,7 @@ class DefaultTxHistoryRepository( return Pager( config = PagingConfig( pageSize = pageSize, + initialLoadSize = pageSize, ), pagingSourceFactory = { TxHistoryPagingSource( diff --git a/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsUseCase.kt b/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsUseCase.kt index 6c9c0f682f..39865a24f5 100644 --- a/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsUseCase.kt +++ b/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsUseCase.kt @@ -10,7 +10,7 @@ import com.tangem.domain.txhistory.repository.TxHistoryRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.catch -private const val DEFAULT_PAGE_SIZE = 20 +private const val DEFAULT_PAGE_SIZE = 50 class GetTxHistoryItemsUseCase(private val repository: TxHistoryRepository) {