Page MenuHomePhabricator

[lib] Pull `useCommunityRootMembersToRole` out of `useThreadSearchIndex`
ClosedPublic

Authored by atul on May 21 2024, 7:22 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 4, 1:36 PM
Unknown Object (File)
Wed, Nov 27, 9:12 AM
Unknown Object (File)
Wed, Nov 27, 3:05 AM
Unknown Object (File)
Nov 23 2024, 12:49 PM
Unknown Object (File)
Nov 9 2024, 5:12 AM
Unknown Object (File)
Nov 8 2024, 5:52 AM
Unknown Object (File)
Nov 5 2024, 6:58 AM
Unknown Object (File)
Nov 5 2024, 6:55 AM
Subscribers
None

Details

Summary

We want to use this logic in useThreadsWithPermission as well so it makes sense to pull it out as a hook instead of copy/pasting code. Especially since the code for creating nested dictionary isn't the easiest to read.

Test Plan

Will add log statements to useThreadSearchIndex to make sure communityRootMemebersToRole gets computed as before.

Will also set breakpoints to check structure of communityRootMembersToRole to make sure it's as expected.


BEFORE (checking constructed communityRootMembersToRole within useSearchIndex with breakpoint):

33f8e2.png (846×804 px, 144 KB)

AFTER (checking return value of useCommunityRootMembersToRole):

d0577f.png (604×726 px, 60 KB)

Note that I wasn't able to get breakpoints to hit in AFTER case for some reason, but I console.logged and made sure that the structure of object was the same.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul published this revision for review.May 21 2024, 7:24 AM
atul added inline comments.
lib/shared/thread-utils.js
158–162 ↗(On Diff #40469)

Would appreciate advice on if this is the right way to type this.

Before creating this type, flow said the return value of useCommunityRootMembersToRole was

lodash.Dictionary<lodash.Dictionary<RoleInfo | null>>

Did RoleInfo | null since it seemed narrower than ?RoleInfo since undefined isn't possible? Not sure if that was the right call, so open to reverting.

tomek added inline comments.
lib/shared/thread-utils.js
158–162 ↗(On Diff #40469)

I don't think it matters too much, and we're using ?Type in most of the other places, so it's probably less confusing to keep this approach.

159–161 ↗(On Diff #40469)
This revision is now accepted and ready to land.May 22 2024, 6:27 AM

address feedback before updating test plan and before landing