Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3352129
D8900.id30184.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
D8900.id30184.diff
View Options
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -45,6 +45,7 @@
usersWithPersonalThreadSelector,
} from '../selectors/user-selectors.js';
import { getUserAvatarForThread } from '../shared/avatar-utils.js';
+import SentencePrefixSearchIndex from '../shared/sentence-prefix-search-index.js';
import type { CalendarQuery } from '../types/entry-types.js';
import { messageTypes } from '../types/message-types-enum.js';
import {
@@ -1758,6 +1759,45 @@
]);
}
+function useChatMentionSearchIndex(): {
+ +[id: string]: SentencePrefixSearchIndex,
+} {
+ const [chatMentionCandidates, resolvedThreadInfos] =
+ useChatMentionCandidatesObjAndResolvedThreadInfos();
+ return React.useMemo(() => {
+ const result = {};
+ const visitedThreads = new Set();
+ for (const threadID in chatMentionCandidates) {
+ if (visitedThreads.has(threadID)) {
+ continue;
+ }
+ visitedThreads.add(threadID);
+ const searchIndex = new SentencePrefixSearchIndex();
+ result[threadID] = searchIndex;
+ searchIndex.addEntry(
+ resolvedThreadInfos[threadID].id,
+ resolvedThreadInfos[threadID].uiName,
+ );
+ for (const key in chatMentionCandidates[threadID]) {
+ result[key] = searchIndex;
+ searchIndex.addEntry(
+ chatMentionCandidates[threadID][key].id,
+ chatMentionCandidates[threadID][key].uiName,
+ );
+ visitedThreads.add(chatMentionCandidates[threadID][key].id);
+ }
+ }
+ return result;
+ }, [chatMentionCandidates, resolvedThreadInfos]);
+}
+
+function useThreadChatMentionSearchIndex(
+ threadInfo: ThreadInfo,
+): SentencePrefixSearchIndex {
+ const chatMentionCandidatesSearchIndex = useChatMentionSearchIndex();
+ return chatMentionCandidatesSearchIndex[threadInfo.id];
+}
+
export {
threadHasPermission,
viewerIsMember,
@@ -1829,4 +1869,5 @@
getThreadsToDeleteText,
useChatMentionCandidatesObj,
useThreadChatMentionCandidates,
+ useThreadChatMentionSearchIndex,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 4:44 AM (18 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2573979
Default Alt Text
D8900.id30184.diff (2 KB)
Attached To
Mode
D8900: [lib] Add chat mention SearchIndex selector
Attached
Detach File
Event Timeline
Log In to Comment