Page MenuHomePhabricator

[lib/web/native] Introduce hook that constructs a resolved user search index and update usePotentialMemberItems
ClosedPublic

Authored by rohan on Dec 7 2023, 11:30 AM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 3 2024, 5:54 PM
Unknown Object (File)
Mar 22 2024, 10:31 PM
Unknown Object (File)
Mar 7 2024, 9:05 AM
Unknown Object (File)
Mar 7 2024, 8:31 AM
Unknown Object (File)
Mar 7 2024, 7:48 AM
Unknown Object (File)
Mar 7 2024, 6:11 AM
Unknown Object (File)
Mar 7 2024, 5:10 AM
Unknown Object (File)
Mar 7 2024, 5:00 AM
Subscribers

Details

Summary

This diff introduces a hook that constructs a resolved user search index. Similar to useThreadSearchIndex, we want to be able to map a user ID to both the raw username and their resolved ENS name (if exists). We do this by:

useUserSearchIndex(userInfos: $ReadOnlyArray<UserInfo>): SearchIndex {
  1. get userInfos WITH ENS names
  2. Construct a map between userInfo.id <-> userInfo
  3. Create an empty search index
  4. Iterate through each userInfo
  5. For each userInfo, append identifying, searchable info related to that user (in this case, it would be their username and, if present, their ENS name)
     If they have an ENS name, their username unresolved would be their wallet address.
  6. Concat the array to be separated by a ' ', i.e. '0x378912479124719 ryan'
  7. Add that to the search index associated with the user id
    --> This makes it so when the search index tokenizes the input, both 0x378912479124719 and ryan will map back to the user id
  8. Return search index
}

This is a lot simpler than useThreadSearchIndex, so it didn't make much sense to reuse the same hook.

Following this, I was able to update all callsites to usePotentialMemberItems to no longer pass in a SearchIndex, and make a one line change to usePotentialMemberItems to call the hook to construct the search index.

There are some additional search experiences that need to be updated, but those will come in the next part of the stack tracked in ENG-5434

Depends on D10229

Addresses ENG-5403 and ENG-5404

Test Plan

Tested all of the existing callsites that call usePotentialMemberItems to verify that I can now prefix-search a user by their ENS name

native:

ComposeSubchannel
MessageListContainer
AddUsersModal
CommunityCreationMembers

web:

ChatThreadComposer
AddMembersModal

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rohan held this revision as a draft.
rohan edited the summary of this revision. (Show Details)
rohan edited the summary of this revision. (Show Details)
rohan edited the test plan for this revision. (Show Details)
rohan edited the test plan for this revision. (Show Details)
rohan edited the test plan for this revision. (Show Details)
rohan published this revision for review.Dec 7 2023, 6:25 PM
rohan edited the test plan for this revision. (Show Details)

code looks good and thanks for creating all the demo videos! going to resign just so someone else can take a look too

Is userSearchIndexForPotentialMembers still used anywhere? If not, can we remove it?
Otherwise LGTM

lib/selectors/nav-selectors.js
79 ↗(On Diff #34403)

Nit

This revision is now accepted and ready to land.Dec 12 2023, 12:35 AM

Is userSearchIndexForPotentialMembers still used anywhere? If not, can we remove it?

Oh, I can see that it's done in D10254, sorry