HomePhabricator
Diffusion Comm 87830f574812

[lib] Detect a valid ENS name in search experiences

Description

[lib] Detect a valid ENS name in search experiences

Summary:
Now that we have a regex to capture a valid ENS name and we have consolidated the search functions that will need to be updated to perform a 'forward lookup', we need to actually make the changes to these two functions (useThreadListSearch and useSearchUsers).

The important change here is the introduction of useForwardLookupSearchText, a hook that will attempt to match the search text to a valid ENS name. If so, it then executes the getAddressForName call (so we can map something like jack.eth to 0x837412947319247 if it's a valid user).

If no matched wallet address is found for the username search text, we just return the original search text.

The approach in both useThreadListSearch and useSearchUsers is functionally the same. Instead of just using the username search text provided from the parameter, we call useForwardLookupSearchText with it to either get the wallet address that matches the ENS user OR default back to the original provided search text.

(Small note: useThreadListSearch already works fine for threads with ENS users).

Addresses ENG-5412, ENG-5414 and ENG-5415.

Depends on D9884

Test Plan:
Please see the attached videos below that covers both web and native. I'm reproducing the final testing task plan to confirm that these changes give the expected results.

web

Searching Inbox
Composing a new chat
Add friends from friends list

native (dev)

Searching Inbox
Composing a new chat
Add friends from friends list

native (prod)

Searching Inbox
Composing a new chat
Add friends from friends list

Reviewers: atul, ginsu, inka

Reviewed By: ginsu

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D9885

Details

Provenance
rohanAuthored on Nov 28 2023, 8:44 AM
Reviewer
ginsu
Differential Revision
D9885: [lib] Detect a valid ENS name in search experiences
Parents
rCOMMd87df9dd068e: [web/native] Use useSearchUsers for the friends list
Branches
Unknown
Tags
Unknown