( threadInfos: ?$ReadOnlyArray<ThreadInfo>, )
| 47 | } |
| 48 | |
| 49 | function useResolvedOptionalThreadInfos( |
| 50 | threadInfos: ?$ReadOnlyArray<ThreadInfo>, |
| 51 | ): ?$ReadOnlyArray<ResolvedThreadInfo> { |
| 52 | const entityText = React.useMemo(() => { |
| 53 | if (!threadInfos) { |
| 54 | return null; |
| 55 | } |
| 56 | return threadInfos.map(threadInfo => |
| 57 | ET.thread({ display: 'uiName', threadInfo }), |
| 58 | ); |
| 59 | }, [threadInfos]); |
| 60 | const resolvedEntityText = useResolvedEntityText(entityText); |
| 61 | return React.useMemo(() => { |
| 62 | if (!threadInfos) { |
| 63 | return threadInfos; |
| 64 | } |
| 65 | invariant( |
| 66 | resolvedEntityText, |
| 67 | 'useResolvedEntityText only returns falsey when passed falsey', |
| 68 | ); |
| 69 | return threadInfos.map((threadInfo, i) => { |
| 70 | if (typeof threadInfo.uiName === 'string') { |
| 71 | // Flow wants return { ...threadInfo, uiName: threadInfo.uiName } |
| 72 | // but that's wasteful and unneeded, so we any-cast here |
| 73 | return (threadInfo: any); |
| 74 | } |
| 75 | const resolvedThreadEntity = resolvedEntityText[i]; |
| 76 | return { |
| 77 | ...threadInfo, |
| 78 | uiName: entityTextToRawString([resolvedThreadEntity]), |
| 79 | }; |
| 80 | }); |
| 81 | }, [threadInfos, resolvedEntityText]); |
| 82 | } |
| 83 | |
| 84 | function useResolvedThreadInfosObj( |
| 85 | threadInfosObj: { |
no test coverage detected