Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32315256
D8900.1765297887.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.1765297887.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
Tue, Dec 9, 4:31 PM (14 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5855398
Default Alt Text
D8900.1765297887.diff (2 KB)
Attached To
Mode
D8900: [lib] Add chat mention SearchIndex selector
Attached
Detach File
Event Timeline
Log In to Comment