Repository navigation
Commit c2cb10b
authored
docs(ai-migration): open the first channel once per load, not after every close (#3358)
Ticket: https://linear.app/stream/issue/REACT-1470
### Goal
Fix the v14 to v15 guide's "No channel opens on load" snippet (section
6, "v14 list defaults that changed"). The current snippet re-subscribes
to the paginator whenever the open channels change, and
`subscribeWithSelector` fires on subscribe, so it opens the first
channel again as soon as the user closes the last one. An app restoring
v14's `setActiveChannelOnMount` default wants it once per load.
### Implementation details
Docs only. The snippet:
- subscribes on `[paginator]` only and reads the navigation through a
ref, so opening or closing a channel does not replay an already loaded
page;
- counts each load once: closing the last channel, or a channel moving
to the top of the list, opens nothing;
- re-arms when the list returns to "never queried" (`items ===
undefined`, where `client.disconnectUser()` resets it), so the next
user's first load opens its first channel;
- checks `openChannels` instead of a `useRef` flag, so a `ChatView` view
switch that remounts it does not replace the channel the user picked.
The bullet under the snippet now describes the once-per-load behavior.
The snippet was checked by extracting it into a temporary hook and
running a test suite against it (initial load, a page loaded before
mount, remount after picking another channel, a `ChatView`
threads/channels view switch, reorder, empty first page, reload after a
reset, no provider): all 8 pass, and it passes ESLint.
### UI Changes
None.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Documentation**
* Updated the migration guide’s `useOpenFirstChannel` example to open
the first channel only when no channel is already open, and to avoid
overriding a channel selected by the user.
* Added guidance on resetting this behavior when a list unloads,
handling disconnect cleanup, and using the hook with multiple lists.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 290d2db commit c2cb10b
1 file changed
Lines changed: 33 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
991 | | - | |
| 991 | + | |
992 | 992 | | |
993 | 993 | | |
994 | | - | |
| 994 | + | |
995 | 995 | | |
996 | 996 | | |
997 | 997 | | |
998 | 998 | | |
999 | 999 | | |
1000 | | - | |
1001 | | - | |
1002 | | - | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
1013 | 1029 | | |
1014 | 1030 | | |
1015 | 1031 | | |
| |||
1021 | 1037 | | |
1022 | 1038 | | |
1023 | 1039 | | |
1024 | | - | |
| 1040 | + | |
| 1041 | + | |
1025 | 1042 | | |
1026 | 1043 | | |
1027 | 1044 | | |
| |||
0 commit comments