Introduce hook containing logic responsible for selecting ChatThreadItems containing child threads with some filter, so it could be used in both Subchannels and Sidebars modals on web.
The hook also adds watching to threads and fetches most recent message from server if necessary, so all threads data are always updated.
The logic is almost completely moved from SubchannelsModal and only some default parameters were added.
Details
Details
- Reviewers
tomek atul - Commits
- rCOMM740dc18c6558: [web] Introduce `useFilteredChildThreads` hook
The subchannels modal should behave in the same way as before change.
Diff Detail
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
| lib/hooks/child-threads.js | ||
|---|---|---|
| 21–24 | Extracting this hook sounds like a good idea, but its API isn't intuitive: especially, it's not clear why do we need to specify search text when using child threads. To improve the API we can e.g.
| |
| 49 | searchText is mandatory at this point - it has a default value "", so optional chaining isn't necessary | |
| lib/hooks/child-threads.js | ||
|---|---|---|
| 30–39 ↗ | (On Diff #14840) | One issue with this is that using the default predicate value would result in unnecessary rerenders. Value of default predicate changes with every render, so this memoization don't work. We should either create a React.useCallback that returns true, or a function defined outside this hook. |
| lib/hooks/child-threads.js | ||
|---|---|---|
| 30–39 ↗ | (On Diff #14840) | Thanks for catching |