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 @@ -1768,30 +1768,12 @@ return chatMentionCandidatesObj; } +const emptyMentionCandidates = {}; function useThreadChatMentionCandidates( + // eslint-disable-next-line no-unused-vars threadInfo: ThreadInfo, ): ChatMentionCandidates { - const { chatMentionCandidatesObj, communityThreadIDForGenesisThreads } = - useChatMentionCandidatesObjAndUtils(); - return React.useMemo(() => { - let communityID, - result = {}; - if (threadInfo.community === genesis.id) { - communityID = communityThreadIDForGenesisThreads[threadInfo.id]; - } else { - communityID = threadInfo.community ?? threadInfo.id; - } - if (chatMentionCandidatesObj[communityID]) { - result = { ...chatMentionCandidatesObj[communityID] }; - } - delete result[threadInfo.id]; - return result; - }, [ - chatMentionCandidatesObj, - communityThreadIDForGenesisThreads, - threadInfo.community, - threadInfo.id, - ]); + return emptyMentionCandidates; } function useUserProfileThreadInfo(userInfo: ?UserInfo): ?UserProfileThreadInfo { @@ -1852,6 +1834,7 @@ ]); } +// eslint-disable-next-line no-unused-vars function useChatMentionSearchIndex(): { +[id: string]: SentencePrefixSearchIndex, } { @@ -1880,20 +1863,12 @@ }, [chatMentionCandidatesObj]); } +const emptySearchIndex = new SentencePrefixSearchIndex(); function useThreadChatMentionSearchIndex( + // eslint-disable-next-line no-unused-vars 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 - ]; + return emptySearchIndex; } export {