Page MenuHomePhabricator

[native] Utilize identity search on native
AbandonedPublic

Authored by will on Feb 13 2024, 2:10 PM.
Tags
None
Referenced Files
F3486099: D11059.diff
Wed, Dec 18, 3:01 AM
Unknown Object (File)
Mon, Dec 16, 11:26 PM
Unknown Object (File)
Mon, Dec 16, 11:26 PM
Unknown Object (File)
Mon, Dec 16, 11:26 PM
Unknown Object (File)
Mon, Dec 16, 7:49 AM
Unknown Object (File)
Wed, Nov 27, 7:52 PM
Unknown Object (File)
Tue, Nov 26, 10:38 AM
Unknown Object (File)
Mon, Nov 25, 7:36 AM
Subscribers

Details

Summary

This uses identity search instead of keyserver search on native for creating new chats and adding friends.

Test Plan

flow and tested on ios simulator at both callsites

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

will requested review of this revision.Feb 13 2024, 2:24 PM

Skipping "request changes" so that @varun can review too

native/chat/message-list-container.react.js
254–255

It appears as if you're issuing queries to both places, but since usingCommServicesAccessToken is a constant, only one will be used.

Is there another way to structure things to avoid this? For instance, what if instead of these hooks, you had hooks that returned a function that would execute the search?

Alternately, what if the search query was executed by a different React component (that this component would render). Then you could pick which place was queried by conditionally rendering one of two React components.

257–261

This is a perfect use case for ternary syntax

native/profile/relationship-list.react.js
127–134

Looks like this logic is the same that you are introducing in MessageListContainer. My comments above will probably make this code a bit more complicated, so I think it's worth considering if you could factor it all out to avoid repeating yourself

native/utils/identity-search-utils.js
15–22

Is this the current best practice? It doesn't look like you'd be able to handle changes to the auth metadata with this approach. @varun can maybe give better feedback here.

native/chat/message-list-container.react.js
254–255

I settled on possible abandoning https://phab.comm.dev/D11049 and https://phab.comm.dev/D11060 and editing the existing useSearchUsers function with a conditional for my identity search functionality.

I probably should have done this at the start because my useSearchIdentityUsers is almost identical to the keyserver search useSearchUsers function but I mistakenly wanted to leave useSearchUsers untouched.

I'll push the diff soon, but I'm unsure if actually having a conditional hook that returns one of two functions would be the better solution.

native/chat/message-list-container.react.js
254–255

I believe this is fine to replace the existing function as all the locations of where we're using useSearchUsers would've eventually been replaced by useSearchIdentityUsers anyway

varun added inline comments.
native/utils/identity-search-utils.js
15–22

we should follow the pattern introduced in IdentityServiceContextProvider (native/identity-service/identity-service-context-provider.react.js).

eventually, we will need to get the userID from currentUserInfo (we should create a new task like https://linear.app/comm/issue/ENG-6649/use-userid-from-currentuserinfo-in-identityservicecontextprovider)

(cc @tomek @inka, please correct me if i'm wrong here)

native/chat/message-list-container.react.js
254–255

Seems reasonable, if I'm interpreting you correctly

native/utils/identity-search-utils.js
15–22

The current best practice is to get this data from IdentityClientContext by calling await getAuthMetadata() method that it exposes. We can't store this data in e.g. state, because it can change - instead, we should await this method every time we need the data.

With accessToken we can safely read it from Redux because we have a handler that listens for the changes and updates the store.

ashoat requested changes to this revision.Feb 15 2024, 7:20 AM
ashoat added inline comments.
native/utils/identity-search-utils.js
15–22

Based on @tomek's comment, it sounds like the authMessage prop to IdentitySearchProvider should be replaced with a function getAuthMessage. Passing back to @will for this, and the other changes requested

This revision now requires changes to proceed.Feb 15 2024, 7:20 AM
will abandoned this revision.EditedFeb 21 2024, 1:28 PM

Abandoning this diff as recent changes to https://phab.comm.dev/D11058 and https://phab.comm.dev/D10938 remove the need for this diff. The authMessage prop is replaced by the useGetIdentitySearchAuthMessage hook in the identity search context provider, removing the need for the useIdentitySearchAuthMessage for passing in the authMessage in native. Additionally, useSearchUsers was modified to include identity search instead of a separate useSearchIdentityUsers function