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
|
next: txNextToken
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if we got more than ITEMS_PER_PAGE transactions
|
// Get all fetched transactions
|
||||||
const fetchedTransactions = result.transactions || [];
|
const fetchedTransactions = result.transactions || [];
|
||||||
|
|
||||||
if (fetchedTransactions.length > ITEMS_PER_PAGE) {
|
// Add all fetched transactions to our array
|
||||||
|
allTransactions = [...allTransactions, ...fetchedTransactions];
|
||||||
allTransactions = [...allTransactions, ...fetchedTransactions.slice(0, ITEMS_PER_PAGE)];
|
|
||||||
|
// 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;
|
hasMoreTransactions = true;
|
||||||
txNextToken = result.nextToken;
|
txNextToken = result.nextToken;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
allTransactions = [...allTransactions, ...fetchedTransactions];
|
|
||||||
hasMoreTransactions = false;
|
hasMoreTransactions = false;
|
||||||
txNextToken = null;
|
txNextToken = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user