From 1431682c43c28a66e590e4a6f0cbcd3ccd3751e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Tranta?= Date: Fri, 7 Feb 2025 11:24:09 +0100 Subject: [PATCH] feat(suite): limit the pagination in trasancation of the end pages and go to end for networks with unrealiable transactions --- .../src/components/wallet/Pagination.tsx | 28 +++++++++++-------- .../TransactionList/TransactionList.tsx | 3 ++ .../TransactionList/WalletTransactionList.tsx | 2 ++ suite-common/wallet-config/src/types.ts | 12 ++++++++ suite-common/wallet-config/src/utils.ts | 18 +++++++----- 5 files changed, 44 insertions(+), 19 deletions(-) diff --git a/packages/suite/src/components/wallet/Pagination.tsx b/packages/suite/src/components/wallet/Pagination.tsx index 8251f75be71..bd5e25a6eca 100644 --- a/packages/suite/src/components/wallet/Pagination.tsx +++ b/packages/suite/src/components/wallet/Pagination.tsx @@ -53,6 +53,7 @@ interface PaginationProps { hasPages?: boolean; perPage: number; totalItems: number; + limitedPageList?: boolean; onPageSelected: (page: number) => void; } @@ -63,6 +64,7 @@ export const Pagination = ({ isLastPage, perPage, totalItems, + limitedPageList, ...rest }: PaginationProps) => { const totalPages = Math.ceil(totalItems / perPage); @@ -98,17 +100,19 @@ export const Pagination = ({ {totalPages ? ( - calculatedPages.map(i => ( - onPageSelected(i)} - $isActive={i === currentPage} - > - {i} - - )) + calculatedPages + .slice(0, limitedPageList ? currentPage + 2 : calculatedPages.length) + .map(i => ( + onPageSelected(i)} + $isActive={i === currentPage} + > + {i} + + )) ) : ( <> {[...Array(currentPage - 1)].map((_p, i) => ( @@ -131,7 +135,7 @@ export const Pagination = ({ onPageSelected(currentPage + 1)}>› - {totalPages && totalPages > 2 && ( + {totalPages && totalPages > 2 && !limitedPageList && ( onPageSelected(totalPages)}>» )} diff --git a/packages/suite/src/views/wallet/transactions/TransactionList/TransactionList.tsx b/packages/suite/src/views/wallet/transactions/TransactionList/TransactionList.tsx index 32c178d9f9c..bc4b9bd768d 100644 --- a/packages/suite/src/views/wallet/transactions/TransactionList/TransactionList.tsx +++ b/packages/suite/src/views/wallet/transactions/TransactionList/TransactionList.tsx @@ -33,6 +33,7 @@ interface TransactionListProps { symbol: WalletAccountTransaction['symbol']; isLoading?: boolean; account: Account; + limitPaging?: boolean; customTotalItems?: number; isExportable?: boolean; customPageFetching?: boolean; @@ -45,6 +46,7 @@ export const TransactionList = ({ isLoading, account, symbol, + limitPaging, customTotalItems, onPageRequested, isExportable = true, @@ -194,6 +196,7 @@ export const TransactionList = ({ {showPagination && ( { return network.displaySymbolName || network.name; }; + +export const areNetworkTransactionsUnreliable = (symbol: NetworkSymbol) => + UNRELIABLE_TRANSACTION_COINS.some(coin => coin === symbol);