Changeset View
Changeset View
Standalone View
Standalone View
lib/components/chat-mention-provider.react.js
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | function ChatMentionContextProvider(props: Props): React.Node { | ||||
return ( | return ( | ||||
<ChatMentionContext.Provider value={value}> | <ChatMentionContext.Provider value={value}> | ||||
{children} | {children} | ||||
</ChatMentionContext.Provider> | </ChatMentionContext.Provider> | ||||
); | ); | ||||
} | } | ||||
function getChatMentionCandidates(resolvedThreadInfos: { | function getChatMentionCandidates( | ||||
+[id: string]: ResolvedThreadInfo, | threadInfos: { +[id: string]: ThreadInfo }, | ||||
}): { | resolvedThreadInfos: { +[id: string]: ResolvedThreadInfo }, | ||||
): { | |||||
chatMentionCandidatesObj: ChatMentionCandidatesObj, | chatMentionCandidatesObj: ChatMentionCandidatesObj, | ||||
communityThreadIDForGenesisThreads: { +[id: string]: string }, | communityThreadIDForGenesisThreads: { +[id: string]: string }, | ||||
} { | } { | ||||
const result: { | const result: { | ||||
[string]: { | [string]: { | ||||
[string]: ResolvedThreadInfo, | [string]: ResolvedThreadInfo, | ||||
}, | }, | ||||
} = {}; | } = {}; | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | |||||
} { | } { | ||||
const threadInfos = useSelector(threadInfoSelector); | const threadInfos = useSelector(threadInfoSelector); | ||||
const resolvedThreadInfos = useResolvedThreadInfosObj( | const resolvedThreadInfos = useResolvedThreadInfosObj( | ||||
threadInfos, | threadInfos, | ||||
useResolvedThreadInfosObjOptions, | useResolvedThreadInfosObjOptions, | ||||
); | ); | ||||
const { chatMentionCandidatesObj, communityThreadIDForGenesisThreads } = | const { chatMentionCandidatesObj, communityThreadIDForGenesisThreads } = | ||||
React.useMemo( | React.useMemo( | ||||
() => getChatMentionCandidates(resolvedThreadInfos), | () => getChatMentionCandidates(threadInfos, resolvedThreadInfos), | ||||
[resolvedThreadInfos], | [threadInfos, resolvedThreadInfos], | ||||
); | ); | ||||
return { | return { | ||||
chatMentionCandidatesObj, | chatMentionCandidatesObj, | ||||
resolvedThreadInfos, | resolvedThreadInfos, | ||||
communityThreadIDForGenesisThreads, | communityThreadIDForGenesisThreads, | ||||
}; | }; | ||||
} | } | ||||
Show All 30 Lines |