Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3486735
D11059.id37044.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
12 KB
Referenced Files
None
Subscribers
None
D11059.id37044.diff
View Options
diff --git a/native/chat/message-list-container.react.js b/native/chat/message-list-container.react.js
--- a/native/chat/message-list-container.react.js
+++ b/native/chat/message-list-container.react.js
@@ -12,6 +12,7 @@
import {
usePotentialMemberItems,
useSearchUsers,
+ useSearchIdentityUsers,
} from 'lib/shared/search-utils.js';
import {
pendingThreadType,
@@ -20,6 +21,7 @@
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { AccountUserInfo, UserListItem } from 'lib/types/user-types.js';
import { pinnedMessageCountText } from 'lib/utils/message-pinning-utils.js';
+import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
import { type MessagesMeasurer, useHeightMeasurer } from './chat-context.js';
import { ChatInputBar } from './chat-input-bar.react.js';
@@ -248,13 +250,21 @@
const otherUserInfos = useSelector(userInfoSelectorForPotentialMembers);
+ let searchResults;
const serverSearchResults = useSearchUsers(usernameInputText);
+ const identitySearchResults = useSearchIdentityUsers(usernameInputText);
+
+ if (usingCommServicesAccessToken) {
+ searchResults = identitySearchResults;
+ } else {
+ searchResults = serverSearchResults;
+ }
const userSearchResults = usePotentialMemberItems({
text: usernameInputText,
userInfos: otherUserInfos,
excludeUserIDs: userInfoInputArray.map(userInfo => userInfo.id),
- includeServerSearchUsers: serverSearchResults,
+ includeServerSearchUsers: searchResults,
});
const [baseThreadInfo, setBaseThreadInfo] = React.useState(
diff --git a/native/profile/relationship-list.react.js b/native/profile/relationship-list.react.js
--- a/native/profile/relationship-list.react.js
+++ b/native/profile/relationship-list.react.js
@@ -13,7 +13,10 @@
import { registerFetchKey } from 'lib/reducers/loading-reducer.js';
import { useUserSearchIndex } from 'lib/selectors/nav-selectors.js';
import { userRelationshipsSelector } from 'lib/selectors/relationship-selectors.js';
-import { useSearchUsers } from 'lib/shared/search-utils.js';
+import {
+ useSearchUsers,
+ useSearchIdentityUsers,
+} from 'lib/shared/search-utils.js';
import {
userRelationshipStatus,
relationshipActions,
@@ -25,6 +28,7 @@
import { useLegacyAshoatKeyserverCall } from 'lib/utils/action-utils.js';
import { values } from 'lib/utils/objects.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
+import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
import type { ProfileNavigationProp } from './profile.react.js';
import RelationshipListItem from './relationship-list-item.react.js';
@@ -119,16 +123,25 @@
$ReadOnlySet<string>,
>(new Set());
+ let searchResults;
const serverSearchResults = useSearchUsers(searchInputText);
+ const identitySearchResults = useSearchIdentityUsers(searchInputText);
+
+ if (usingCommServicesAccessToken) {
+ searchResults = identitySearchResults;
+ } else {
+ searchResults = serverSearchResults;
+ }
+
const filteredServerSearchResults = React.useMemo(
() =>
- serverSearchResults.filter(searchUserInfo => {
+ searchResults.filter(searchUserInfo => {
const userInfo = userInfos[searchUserInfo.id];
return (
!userInfo || !excludeStatuses.includes(userInfo.relationshipStatus)
);
}),
- [serverSearchResults, userInfos, excludeStatuses],
+ [searchResults, userInfos, excludeStatuses],
);
const userStoreSearchIndex = useUserSearchIndex(userInfosArray);
diff --git a/native/root.react.js b/native/root.react.js
--- a/native/root.react.js
+++ b/native/root.react.js
@@ -30,6 +30,7 @@
import KeyserverConnectionsHandler from 'lib/components/keyserver-connections-handler.js';
import { MediaCacheProvider } from 'lib/components/media-cache-provider.react.js';
import { StaffContextProvider } from 'lib/components/staff-provider.react.js';
+import { IdentitySearchProvider } from 'lib/identity-search/identity-search-context.js';
import { CallKeyserverEndpointProvider } from 'lib/keyserver-conn/call-keyserver-endpoint-provider.react.js';
import { TunnelbrokerProvider } from 'lib/tunnelbroker/tunnelbroker-context.js';
import { actionLogger } from 'lib/utils/action-logger.js';
@@ -80,6 +81,7 @@
import { DarkTheme, LightTheme } from './themes/navigation.js';
import ThemeHandler from './themes/theme-handler.react.js';
import { provider } from './utils/ethers-utils.js';
+import { useIdentitySearchAuthMessage } from './utils/identity-search-utils.js';
import { useTunnelbrokerInitMessage } from './utils/tunnelbroker-utils.js';
// Add custom items to expo-dev-menu
@@ -263,6 +265,7 @@
})();
const tunnelbrokerInitMessage = useTunnelbrokerInitMessage();
+ const identitySearchAuthMessage = useIdentitySearchAuthMessage();
const gated: React.Node = (
<>
@@ -308,56 +311,60 @@
initMessage={tunnelbrokerInitMessage}
peerToPeerMessageHandler={peerToPeerMessageHandler}
>
- <FeatureFlagsProvider>
- <NavContext.Provider value={navContext}>
- <RootContext.Provider value={rootContext}>
- <InputStateContainer>
- <MessageEditingContextProvider>
- <SafeAreaProvider initialMetrics={initialWindowMetrics}>
- <ActionSheetProvider>
- <ENSCacheProvider provider={provider}>
- <MediaCacheProvider
- persistence={filesystemMediaCache}
- >
- <EditUserAvatarProvider>
- <NativeEditThreadAvatarProvider>
- <MarkdownContextProvider>
- <MessageSearchProvider>
- <BottomSheetProvider>
- <RegistrationContextProvider>
- <SQLiteDataHandler />
- <ConnectedStatusBar />
- <ReduxPersistGate
- persistor={getPersistor()}
- >
- {gated}
- </ReduxPersistGate>
- <PersistedStateGate>
- <KeyserverConnectionsHandler
- socketComponent={Socket}
- detectUnsupervisedBackgroundRef={
- detectUnsupervisedBackgroundRef
- }
- />
- <VersionSupportedChecker />
- <PrekeysHandler />
- </PersistedStateGate>
- {navigation}
- </RegistrationContextProvider>
- </BottomSheetProvider>
- </MessageSearchProvider>
- </MarkdownContextProvider>
- </NativeEditThreadAvatarProvider>
- </EditUserAvatarProvider>
- </MediaCacheProvider>
- </ENSCacheProvider>
- </ActionSheetProvider>
- </SafeAreaProvider>
- </MessageEditingContextProvider>
- </InputStateContainer>
- </RootContext.Provider>
- </NavContext.Provider>
- </FeatureFlagsProvider>
+ <IdentitySearchProvider authMessage={identitySearchAuthMessage}>
+ <FeatureFlagsProvider>
+ <NavContext.Provider value={navContext}>
+ <RootContext.Provider value={rootContext}>
+ <InputStateContainer>
+ <MessageEditingContextProvider>
+ <SafeAreaProvider
+ initialMetrics={initialWindowMetrics}
+ >
+ <ActionSheetProvider>
+ <ENSCacheProvider provider={provider}>
+ <MediaCacheProvider
+ persistence={filesystemMediaCache}
+ >
+ <EditUserAvatarProvider>
+ <NativeEditThreadAvatarProvider>
+ <MarkdownContextProvider>
+ <MessageSearchProvider>
+ <BottomSheetProvider>
+ <RegistrationContextProvider>
+ <SQLiteDataHandler />
+ <ConnectedStatusBar />
+ <ReduxPersistGate
+ persistor={getPersistor()}
+ >
+ {gated}
+ </ReduxPersistGate>
+ <PersistedStateGate>
+ <KeyserverConnectionsHandler
+ socketComponent={Socket}
+ detectUnsupervisedBackgroundRef={
+ detectUnsupervisedBackgroundRef
+ }
+ />
+ <VersionSupportedChecker />
+ <PrekeysHandler />
+ </PersistedStateGate>
+ {navigation}
+ </RegistrationContextProvider>
+ </BottomSheetProvider>
+ </MessageSearchProvider>
+ </MarkdownContextProvider>
+ </NativeEditThreadAvatarProvider>
+ </EditUserAvatarProvider>
+ </MediaCacheProvider>
+ </ENSCacheProvider>
+ </ActionSheetProvider>
+ </SafeAreaProvider>
+ </MessageEditingContextProvider>
+ </InputStateContainer>
+ </RootContext.Provider>
+ </NavContext.Provider>
+ </FeatureFlagsProvider>
+ </IdentitySearchProvider>
</TunnelbrokerProvider>
</OlmSessionCreatorProvider>
</IdentityServiceContextProvider>
diff --git a/native/utils/identity-search-utils.js b/native/utils/identity-search-utils.js
new file mode 100644
--- /dev/null
+++ b/native/utils/identity-search-utils.js
@@ -0,0 +1,37 @@
+// @flow
+
+import * as React from 'react';
+
+import type { AuthMessage } from 'lib/types/identity-search/auth-message-types.js';
+
+import { commCoreModule } from '../native-modules.js';
+import { useSelector } from '../redux/redux-utils.js';
+
+function useIdentitySearchAuthMessage(): ?AuthMessage {
+ const [deviceID, setDeviceID] = React.useState<?string>();
+ const [userID, setUserID] = React.useState<?string>();
+ const accessToken = useSelector(state => state.commServicesAccessToken);
+
+ React.useEffect(() => {
+ void (async () => {
+ const { userID: identityUserID, deviceID: contentSigningKey } =
+ await commCoreModule.getCommServicesAuthMetadata();
+ setDeviceID(contentSigningKey);
+ setUserID(identityUserID);
+ })();
+ }, [accessToken]);
+
+ return React.useMemo(() => {
+ if (!deviceID || !accessToken || !userID) {
+ return null;
+ }
+ return ({
+ type: 'AuthMessage',
+ deviceID,
+ accessToken,
+ userID,
+ }: AuthMessage);
+ }, [accessToken, deviceID, userID]);
+}
+
+export { useIdentitySearchAuthMessage };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 5:49 AM (20 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675117
Default Alt Text
D11059.id37044.diff (12 KB)
Attached To
Mode
D11059: [native] Utilize identity search on native
Attached
Detach File
Event Timeline
Log In to Comment