feat: Refine transaction pagination logic
This commit is contained in:
parent
354e5bbb6e
commit
399acbeccf
15
index.html
15
index.html
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user