Skip to content

Commit

Permalink
Revert "[lib] Disable chat mentioning"
Browse files Browse the repository at this point in the history
Summary: This reverts commit 2a40ae7.

Test Plan: Check if the chat mentions are being displayed.

Reviewers: kamil, inka, atul

Reviewed By: atul

Subscribers: ashoat, wyilio

Differential Revision: https://phab.comm.dev/D9465
  • Loading branch information
palys-swm committed Oct 19, 2023
1 parent 8802233 commit 0fe8423
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions lib/shared/thread-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1768,12 +1768,30 @@ function useChatMentionCandidatesObj(): ChatMentionCandidatesObj {
return chatMentionCandidatesObj;
}

const emptyMentionCandidates = {};
function useThreadChatMentionCandidates(
// eslint-disable-next-line no-unused-vars
threadInfo: ThreadInfo,
): ChatMentionCandidates {
return emptyMentionCandidates;
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,
]);
}

function useUserProfileThreadInfo(userInfo: ?UserInfo): ?UserProfileThreadInfo {
Expand Down Expand Up @@ -1834,7 +1852,6 @@ function useUserProfileThreadInfo(userInfo: ?UserInfo): ?UserProfileThreadInfo {
]);
}

// eslint-disable-next-line no-unused-vars
function useChatMentionSearchIndex(): {
+[id: string]: SentencePrefixSearchIndex,
} {
Expand Down Expand Up @@ -1863,12 +1880,20 @@ function useChatMentionSearchIndex(): {
}, [chatMentionCandidatesObj]);
}

const emptySearchIndex = new SentencePrefixSearchIndex();
function useThreadChatMentionSearchIndex(
// eslint-disable-next-line no-unused-vars
threadInfo: ThreadInfo,
): SentencePrefixSearchIndex {
return emptySearchIndex;
const chatMentionCandidatesSearchIndex = useChatMentionSearchIndex();
const { communityThreadIDForGenesisThreads } =
useChatMentionCandidatesObjAndUtils();
if (threadInfo.community === genesis.id) {
return chatMentionCandidatesSearchIndex[
communityThreadIDForGenesisThreads[threadInfo.id]
];
}
return chatMentionCandidatesSearchIndex[
threadInfo.community ?? threadInfo.id
];
}

export {
Expand Down

0 comments on commit 0fe8423

Please sign in to comment.