()
| 61 | import { useSelector } from '../utils/redux-utils.js'; |
| 62 | |
| 63 | function useChildThreadInfosMap(): { |
| 64 | +[id: string]: $ReadOnlyArray<ResolvedThreadInfo>, |
| 65 | } { |
| 66 | const childThreadInfosMap = useSelector(childThreadInfos); |
| 67 | |
| 68 | const { getCommunityThreadIDForGenesisThreads, chatMentionCandidatesObj } = |
| 69 | useChatMentionContext(); |
| 70 | |
| 71 | return React.useMemo(() => { |
| 72 | const result: { [id: string]: $ReadOnlyArray<ResolvedThreadInfo> } = {}; |
| 73 | for (const parentThreadID in childThreadInfosMap) { |
| 74 | result[parentThreadID] = childThreadInfosMap[parentThreadID] |
| 75 | .map(rawThreadInfo => { |
| 76 | const communityThreadIDForGenesisThreads = |
| 77 | getCommunityThreadIDForGenesisThreads(rawThreadInfo); |
| 78 | const community = |
| 79 | rawThreadInfo.community === genesis().id |
| 80 | ? communityThreadIDForGenesisThreads |
| 81 | : (rawThreadInfo.community ?? rawThreadInfo.id); |
| 82 | if (!community) { |
| 83 | return undefined; |
| 84 | } |
| 85 | const communityThreads = chatMentionCandidatesObj[community]; |
| 86 | if (!communityThreads) { |
| 87 | return undefined; |
| 88 | } |
| 89 | return communityThreads[rawThreadInfo.id]?.threadInfo; |
| 90 | }) |
| 91 | .filter(Boolean); |
| 92 | } |
| 93 | return result; |
| 94 | }, [ |
| 95 | childThreadInfosMap, |
| 96 | getCommunityThreadIDForGenesisThreads, |
| 97 | chatMentionCandidatesObj, |
| 98 | ]); |
| 99 | } |
| 100 | |
| 101 | function useNewThickThread(): ( |
| 102 | input: NewThickThreadRequest, |
no test coverage detected