From 22e222ffd6c0ea7bd1851a36ce2e64e9fc8f32cb Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 20 Jul 2023 14:48:12 -0500 Subject: [PATCH] paginate inscription responses --- lib/services/litescribe_api.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/services/litescribe_api.dart b/lib/services/litescribe_api.dart index edb46f1d2..abc28123e 100644 --- a/lib/services/litescribe_api.dart +++ b/lib/services/litescribe_api.dart @@ -48,9 +48,10 @@ class LitescribeAPI { if (currentSize == size && currentSize < total) { // If the number of returned inscriptions equals the limit and there are more inscriptions available, - // increase the size to fetch all inscriptions. - return getInscriptionsByAddress(address, cursor: cursor, size: total+1); // potential off-by-one error, but should be safe - // 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 + // increment the cursor and make the next API call to fetch the remaining inscriptions. + final int newCursor = cursor + size; + return getInscriptionsByAddress(address, cursor: newCursor, size: size); + // TODO test logic with smaller size "pagination" } else { try { return AddressInscriptionResponse.fromJson(response.data as Map);