feat: Refine transaction pagination logic

This commit is contained in:
void-57 2025-12-17 05:26:55 +05:30
parent 354e5bbb6e
commit 399acbeccf

View File

@ -1211,17 +1211,20 @@
next: txNextToken
});
// Check if we got more than ITEMS_PER_PAGE transactions
// Get all fetched transactions
const fetchedTransactions = result.transactions || [];
if (fetchedTransactions.length > ITEMS_PER_PAGE) {
allTransactions = [...allTransactions, ...fetchedTransactions.slice(0, ITEMS_PER_PAGE)];
// Add all fetched transactions to our array
allTransactions = [...allTransactions, ...fetchedTransactions];
// Determine if there are more transactions:
// If we got exactly limit+1 transactions, there might be more
// Also check the API's hasMore flag
if (fetchedTransactions.length === ITEMS_PER_PAGE + 1 && result.hasMore) {
hasMoreTransactions = true;
txNextToken = result.nextToken;
} else {
allTransactions = [...allTransactions, ...fetchedTransactions];
hasMoreTransactions = false;
txNextToken = null;
}