Skip to content

fix: block prev pagination while another query is loading - #1891

Open
RaphaelFakhri wants to merge 1 commit into
GetStream:masterfrom
RaphaelFakhri:fix/paginator-prev-while-loading
Open

RaphaelFakhri wants to merge 1 commit into
GetStream:masterfrom
RaphaelFakhri:fix/paginator-prev-while-loading

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Title: fix: block prev pagination while another query is loading

CLA

  • I have signed the Stream CLA (required).
  • Code changes are tested

Description of the changes, What, Why and How?

BasePaginator.canExecuteQuery only checked isLoading for the next direction because of operator precedence: (!isLoading && next && hasNext) || (prev && hasPrev). Calling prev() twice quickly sent two requests with the same cursor, and both results were appended to items.

The isLoading check now applies to both directions. A test in BasePaginator.test.ts starts a prev() query, calls prev() again while it is in flight, and checks that only one query is dispatched. The test fails on the previous code (3 query calls instead of 2) and passes with this change.

Changelog

  • Prevent duplicate prev page queries while a paginator is loading.

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.

1 participant