Skip to content

fix(pagination): count a page set with setItems as loaded, even when empty - #1995

Open
oliverlaz wants to merge 1 commit into
release-v10from
fix/paginator-loaded-empty-page
Open

oliverlaz wants to merge 1 commit into
release-v10from
fix/paginator-loaded-empty-page

Conversation

@oliverlaz

Copy link
Copy Markdown
Member

Ticket: https://linear.app/stream/issue/REACT-1475

CLA

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

Description of the changes, What, Why and How?

Found in the second side-by-side QA round (React examples/vite, v15 + v10). The v15 "Unread" channel list could open with no request and show only some unread channels.

Why: a live event can route a channel into a list that was never queried (a message makes a channel unread before the "Unread" list was ever shown). The channel goes into the paginator's logical head interval, so items becomes defined although no page was loaded. stream-chat-react's ChannelList ran its first query only while items === undefined, so it skipped it. isInitialized can't replace that check: an empty setItems page, which the example uses to seed a catch-all list that must never query, leaves it false too. From the outside, both states looked the same.

What / How (BasePaginator):

  • New getter hasLoadedPage: true after a query or any setItems page, including an empty one, and false for items that only events ingested. isInitialized is unchanged, so connection recovery (ChannelManager.recover) still skips a seeded empty list.
  • setItems sets the flag before it publishes, and resetState clears it (and the query shape) before it publishes, so state subscribers such as a UI selector read current values.

Checks: yarn lint, yarn types and yarn test (4950 passed). The suite reports 2 unhandled errors from thread and poll tests, also reported before this change. Verified in the vite example against a local build: after a live message made a channel unread, opening "Unread" sends the query and lists all three unread channels, where it used to list only the event-routed one. The seeded catch-all list still sends no query.

The stream-chat-react half is in GetStream/stream-chat-react#3364 (fix(ChannelList), same ticket). It needs a release with this getter.

Changelog

  • Added BasePaginator.hasLoadedPage: whether a page was loaded by a query or setItems (including an empty one), as opposed to items that only live events ingested into a never-queried list.

…empty

A live event can ingest a channel into a list that was never queried. That defines `items`
without loading a page, so a UI that runs the first query only while `items === undefined`
skipped it, and the list showed just the event-routed channels (stream-chat-react's Unread
view missed unread channels). `isInitialized` cannot replace that check: an empty
`setItems` page (a catch-all list seeded so it never queries) leaves it false too.

Add `BasePaginator.hasLoadedPage`: true after a query or any `setItems` page, including an
empty one, and false for items that only events ingested. `isInitialized` is unchanged, so
connection recovery still skips a seeded empty list. `setItems` sets the flag and
`resetState` clears it (and the query shape) before publishing, so subscribers read current
values.
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