Page MenuHomePhabricator

[lib] Detect a valid ENS name in search experiences
ClosedPublic

Authored by rohan on Nov 14 2023, 11:26 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 15, 9:26 PM
Unknown Object (File)
Thu, Dec 5, 6:58 AM
Unknown Object (File)
Mon, Dec 2, 4:33 AM
Unknown Object (File)
Nov 29 2024, 10:43 PM
Unknown Object (File)
Nov 29 2024, 9:57 PM
Unknown Object (File)
Nov 29 2024, 9:48 PM
Unknown Object (File)
Nov 29 2024, 8:58 PM
Unknown Object (File)
Nov 29 2024, 7:16 PM
Subscribers

Details

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

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

rohan held this revision as a draft.
rohan edited the test plan for this revision. (Show Details)
rohan edited the test plan for this revision. (Show Details)

Lowercase search text for ENS names

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.Nov 15 2023, 8:20 AM
rohan edited the test plan for this revision. (Show Details)

Love the detailed test plan and all the videos!

Attempt rebase after Flow stack

Same comment as here. @atul, @inka, @ginsu – please review this diff ASAP.

LGTM, again sorry for not reviewing this sooner.

This is probs outside the scope of this diff, but I wonder if we should add some debouncing in useForwardLookupSearchText (or somewhere else better in the search logic) so that we are making calls to the server immediately every time text input is changed

This revision is now accepted and ready to land.Nov 28 2023, 1:47 PM
In D9885#293489, @ginsu wrote:

This is probs outside the scope of this diff, but I wonder if we should add some debouncing in useForwardLookupSearchText (or somewhere else better in the search logic) so that we are making calls to the server immediately every time text input is changed

Followed up with @ginsu on Comm regarding this - here's a task to track this suggestion: https://linear.app/comm/issue/ENG-5974/consider-using-debounce-when-forward-searching-ens-users