Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33211330
D8900.1768551186.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D8900.1768551186.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 {
@@ -1855,6 +1856,50 @@
]);
}
+function useChatMentionSearchIndex(): {
+ +[id: string]: SentencePrefixSearchIndex,
+} {
+ const { chatMentionCandidatesObj } = useChatMentionCandidatesObjAndUtils();
+ return React.useMemo(() => {
+ const result = {};
+ for (const communityThreadID in chatMentionCandidatesObj) {
+ const searchIndex = new SentencePrefixSearchIndex();
+ const searchIndexEntries = [];
+ for (const threadID in chatMentionCandidatesObj[communityThreadID]) {
+ searchIndexEntries.push({
+ id: threadID,
+ uiName: chatMentionCandidatesObj[communityThreadID][threadID].uiName,
+ });
+ }
+ // Sort the keys so that the order of the search result is consistent
+ searchIndexEntries.sort(({ uiName: uiNameA }, { uiName: uiNameB }) =>
+ uiNameA.localeCompare(uiNameB),
+ );
+ for (const { id, uiName } of searchIndexEntries) {
+ searchIndex.addEntry(id, uiName);
+ }
+ result[communityThreadID] = searchIndex;
+ }
+ return result;
+ }, [chatMentionCandidatesObj]);
+}
+
+function useThreadChatMentionSearchIndex(
+ threadInfo: ThreadInfo,
+): SentencePrefixSearchIndex {
+ const chatMentionCandidatesSearchIndex = useChatMentionSearchIndex();
+ const { communityThreadIDForGenesisThreads } =
+ useChatMentionCandidatesObjAndUtils();
+ if (threadInfo.community === genesis.id) {
+ return chatMentionCandidatesSearchIndex[
+ communityThreadIDForGenesisThreads[threadInfo.id]
+ ];
+ }
+ return chatMentionCandidatesSearchIndex[
+ threadInfo.community ?? threadInfo.id
+ ];
+}
+
export {
threadHasPermission,
viewerIsMember,
@@ -1925,4 +1970,5 @@
useChatMentionCandidatesObj,
useThreadChatMentionCandidates,
useUserProfileThreadInfo,
+ useThreadChatMentionSearchIndex,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 16, 8:13 AM (4 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5936711
Default Alt Text
D8900.1768551186.diff (2 KB)
Attached To
Mode
D8900: [lib] Add chat mention SearchIndex selector
Attached
Detach File
Event Timeline
Log In to Comment