Repository navigation
Commit bfff3c8
authored
fix(pagination): count a page set with setItems as loaded, even when empty (#1995)
Ticket: https://linear.app/stream/issue/REACT-1475
## CLA
- [x] I have signed the [Stream
CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform)
(required).
- [x] 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.1 parent f5d1a2d commit bfff3c8
2 files changed
Lines changed: 98 additions & 3 deletions
File tree
- src/pagination/paginators
- test/unit/pagination/paginators
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
| 532 | + | |
| 533 | + | |
532 | 534 | | |
533 | 535 | | |
534 | 536 | | |
| |||
645 | 647 | | |
646 | 648 | | |
647 | 649 | | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
648 | 662 | | |
649 | 663 | | |
650 | 664 | | |
| |||
2682 | 2696 | | |
2683 | 2697 | | |
2684 | 2698 | | |
| 2699 | + | |
| 2700 | + | |
2685 | 2701 | | |
2686 | 2702 | | |
2687 | 2703 | | |
| |||
3450 | 3466 | | |
3451 | 3467 | | |
3452 | 3468 | | |
| 3469 | + | |
| 3470 | + | |
| 3471 | + | |
| 3472 | + | |
| 3473 | + | |
3453 | 3474 | | |
3454 | 3475 | | |
3455 | 3476 | | |
3456 | 3477 | | |
3457 | | - | |
3458 | | - | |
3459 | | - | |
3460 | 3478 | | |
3461 | 3479 | | |
3462 | 3480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4534 | 4534 | | |
4535 | 4535 | | |
4536 | 4536 | | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
| 4540 | + | |
| 4541 | + | |
| 4542 | + | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
| 4547 | + | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
| 4551 | + | |
| 4552 | + | |
| 4553 | + | |
| 4554 | + | |
| 4555 | + | |
| 4556 | + | |
| 4557 | + | |
| 4558 | + | |
| 4559 | + | |
| 4560 | + | |
| 4561 | + | |
| 4562 | + | |
| 4563 | + | |
| 4564 | + | |
| 4565 | + | |
| 4566 | + | |
| 4567 | + | |
| 4568 | + | |
| 4569 | + | |
| 4570 | + | |
| 4571 | + | |
| 4572 | + | |
| 4573 | + | |
| 4574 | + | |
| 4575 | + | |
| 4576 | + | |
| 4577 | + | |
| 4578 | + | |
| 4579 | + | |
| 4580 | + | |
| 4581 | + | |
| 4582 | + | |
| 4583 | + | |
| 4584 | + | |
| 4585 | + | |
| 4586 | + | |
| 4587 | + | |
| 4588 | + | |
| 4589 | + | |
| 4590 | + | |
| 4591 | + | |
| 4592 | + | |
| 4593 | + | |
| 4594 | + | |
| 4595 | + | |
| 4596 | + | |
| 4597 | + | |
| 4598 | + | |
| 4599 | + | |
| 4600 | + | |
| 4601 | + | |
| 4602 | + | |
| 4603 | + | |
| 4604 | + | |
| 4605 | + | |
| 4606 | + | |
| 4607 | + | |
| 4608 | + | |
| 4609 | + | |
| 4610 | + | |
| 4611 | + | |
| 4612 | + | |
| 4613 | + | |
4537 | 4614 | | |
4538 | 4615 | | |
4539 | 4616 | | |
| |||
0 commit comments