mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
paginate inscription responses
This commit is contained in:
parent
a322c13954
commit
22e222ffd6
1 changed files with 4 additions and 3 deletions
|
@ -48,9 +48,10 @@ class LitescribeAPI {
|
||||||
|
|
||||||
if (currentSize == size && currentSize < total) {
|
if (currentSize == size && currentSize < total) {
|
||||||
// If the number of returned inscriptions equals the limit and there are more inscriptions available,
|
// If the number of returned inscriptions equals the limit and there are more inscriptions available,
|
||||||
// increase the size to fetch all inscriptions.
|
// increment the cursor and make the next API call to fetch the remaining inscriptions.
|
||||||
return getInscriptionsByAddress(address, cursor: cursor, size: total+1); // potential off-by-one error, but should be safe
|
final int newCursor = cursor + size;
|
||||||
// TODO don't re-request the same inscriptions previously returned; increment cursor (probably) by size and only request the rest. ex: cursor=0 size=1000 probably returns inscriptions 0-999, so set cursor=size (or size-1?) to get 1000-1999
|
return getInscriptionsByAddress(address, cursor: newCursor, size: size);
|
||||||
|
// TODO test logic with smaller size "pagination"
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
return AddressInscriptionResponse.fromJson(response.data as Map<String, dynamic>);
|
return AddressInscriptionResponse.fromJson(response.data as Map<String, dynamic>);
|
||||||
|
|
Loading…
Reference in a new issue