Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3486805
D11001.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11001.diff
View Options
diff --git a/lib/identity-search/identity-search-context.js b/lib/identity-search/identity-search-context.js
--- a/lib/identity-search/identity-search-context.js
+++ b/lib/identity-search/identity-search-context.js
@@ -16,7 +16,6 @@
identitySearchMessageToServerTypes,
identitySearchMessageToClientValidator,
} from '../types/identity-search/messages.js';
-import { identitySearchMessageToServerTypes } from '../types/identity-search/messages.js';
import {
type SearchQuery,
type Prefix,
diff --git a/lib/shared/search-utils.js b/lib/shared/search-utils.js
--- a/lib/shared/search-utils.js
+++ b/lib/shared/search-utils.js
@@ -19,12 +19,14 @@
} from '../actions/user-actions.js';
import { ENSCacheContext } from '../components/ens-cache-provider.react.js';
import genesis from '../facts/genesis.js';
+import { useIdentitySearch } from '../identity-search/identity-search-context.js';
import type {
ChatMessageInfoItem,
MessageListData,
} from '../selectors/chat-selectors.js';
import { useUserSearchIndex } from '../selectors/nav-selectors.js';
import { relationshipBlockedInEitherDirection } from '../shared/relationship-utils.js';
+import type { User } from '../types/identity-search/search-response-types.js';
import type { MessageInfo, RawMessageInfo } from '../types/message-types.js';
import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
import { userRelationshipStatus } from '../types/relationship-types.js';
@@ -369,6 +371,42 @@
return usernameToSearch;
}
+function useSearchIdentityUsers(
+ usernameInputText: string,
+): $ReadOnlyArray<User> {
+ const currentUserID = useSelector(
+ state => state.currentUserInfo && state.currentUserInfo.id,
+ );
+
+ const { sendPrefixQuery } = useIdentitySearch();
+ const [searchResults, setSearchResults] = React.useState(
+ ([]: $ReadOnlyArray<User>),
+ );
+
+ const forwardLookupSearchText = useForwardLookupSearchText(usernameInputText);
+
+ React.useEffect(() => {
+ if (forwardLookupSearchText.length === 0) {
+ setSearchResults([]);
+ return;
+ }
+
+ void (async () => {
+ try {
+ const result = await sendPrefixQuery(forwardLookupSearchText);
+ setSearchResults(
+ result.filter(({ userID }) => userID !== currentUserID),
+ );
+ } catch (err) {
+ console.error(err);
+ setSearchResults([]);
+ }
+ })();
+ }, [currentUserID, forwardLookupSearchText, sendPrefixQuery]);
+
+ return searchResults;
+}
+
function useSearchUsers(
usernameInputText: string,
): $ReadOnlyArray<GlobalAccountUserInfo> {
@@ -446,6 +484,7 @@
notFriendNotice,
useSearchMessages,
useSearchUsers,
+ useSearchIdentityUsers,
filterChatMessageInfosForSearch,
useForwardLookupSearchText,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 5:58 AM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675607
Default Alt Text
D11001.diff (2 KB)
Attached To
Mode
D11001: [lib] identity search function
Attached
Detach File
Event Timeline
Log In to Comment