Page MenuHomePhabricator

[lib] Introduce `useThreadsInChatList` and consume in `useFilteredChildThreads`
ClosedPublic

Authored by atul on May 8 2024, 6:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 22, 7:21 PM
Unknown Object (File)
Sun, Dec 22, 7:21 PM
Unknown Object (File)
Sun, Dec 22, 7:21 PM
Unknown Object (File)
Sun, Dec 22, 7:21 PM
Unknown Object (File)
Sun, Dec 22, 7:21 PM
Unknown Object (File)
Sun, Dec 22, 7:21 PM
Unknown Object (File)
Wed, Dec 11, 6:19 AM
Unknown Object (File)
Fri, Dec 6, 6:09 AM
Subscribers
None

Details

Summary

We want to replace usages of threadInChatList with the useThreadInChatList hook. However, similar to what we ran into with D11924, there are situations where we need to do the check on a list of ThreadInfos instead of a single one. We can't use the useThreadInChatList hook within a for-loop or .filter() block, so we need to introduce a new hook which handles the iteration "inside." Thankfully, we can consume useThreadsWithPermission within useThreadsInChatList so we can reuse that existing logic.


Depends on D11925

Test Plan

flow and close reading

Add log statements to useFilteredChildThreads and ensure return value of threadInChatList and useThreadsInChatList are identical.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul published this revision for review.May 8 2024, 6:42 PM
atul added inline comments.
lib/hooks/child-threads.js
66–86 ↗(On Diff #39957)

Focused on getting this correct, will do another pass to see if this logic can be simplified

lib/hooks/child-threads.js
66–68 ↗(On Diff #39957)

Right off the bat this should be memoized, will update diff

tomek added inline comments.
lib/hooks/child-threads.js
66 ↗(On Diff #39957)

This name might be a bit confusing

This revision is now accepted and ready to land.May 9 2024, 3:54 AM

address feedback before landing