Skip to content

fix(pagination): use limit+1 heuristic for hasNext/hasPrev - #275

Merged
RaceeyXo merged 2 commits into
RaceeyXo:devfrom
Trusty08:fix/pagination-hasnext-heuristic
Sep 1, 2026
Merged

fix(pagination): use limit+1 heuristic for hasNext/hasPrev#275
RaceeyXo merged 2 commits into
RaceeyXo:devfrom
Trusty08:fix/pagination-hasnext-heuristic

Conversation

@Trusty08

@Trusty08 Trusty08 commented Aug 29, 2026

Copy link
Copy Markdown

Closes #227


  • Replace flawed
    ecords.length >= limit\ heuristic with limit+1 approach in both usePayments and useTransactionHistory. Requesting one extra record from Horizon means hasNext is true only when a further page genuinely exists, fixing the off-by-one for accounts whose total record count is an exact multiple of the page size.

  • Fix cursor-nulling bug: nextRef/prevRef are now set unconditionally from the Horizon response instead of being nulled when records.length === 0. Landing on an empty page no longer destroys the ability to navigate back.

  • Empty-page UX: when fetchNext/fetchPrev returns zero records the hook keeps the current page displayed and sets hasNext/hasPrev false, rather than replacing the list with an empty array.

  • Document both behaviours in JSDoc on each hook.

  • Add regression tests covering: exact-limit boundary (hasNext false), limit+1 boundary (hasNext true), empty-page survival (fetchPrev still callable), and hasPrev boundary case. All testnet addresses only.

- Replace flawed \
ecords.length >= limit\ heuristic with limit+1 approach
  in both usePayments and useTransactionHistory. Requesting one extra record
  from Horizon means hasNext is true only when a further page genuinely exists,
  fixing the off-by-one for accounts whose total record count is an exact
  multiple of the page size.

- Fix cursor-nulling bug: nextRef/prevRef are now set unconditionally from
  the Horizon response instead of being nulled when records.length === 0.
  Landing on an empty page no longer destroys the ability to navigate back.

- Empty-page UX: when fetchNext/fetchPrev returns zero records the hook keeps
  the current page displayed and sets hasNext/hasPrev false, rather than
  replacing the list with an empty array.

- Document both behaviours in JSDoc on each hook.

- Add regression tests covering: exact-limit boundary (hasNext false),
  limit+1 boundary (hasNext true), empty-page survival (fetchPrev still
  callable), and hasPrev boundary case. All testnet addresses only.
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Trusty08 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Trusty08

Copy link
Copy Markdown
Author

closes #227

@RaceeyXo
RaceeyXo merged commit b837c0a into RaceeyXo:dev Sep 1, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(hooks): hasNext heuristic strands users on an empty page

2 participants