( threadInfos: $ReadOnlyArray<ThreadInfo>, options?: ?UseResolvedEntityTextOptions, )
| 16 | import { values } from '../utils/objects.js'; |
| 17 | |
| 18 | function useResolvedThreadInfos( |
| 19 | threadInfos: $ReadOnlyArray<ThreadInfo>, |
| 20 | options?: ?UseResolvedEntityTextOptions, |
| 21 | ): $ReadOnlyArray<ResolvedThreadInfo> { |
| 22 | const entityText = React.useMemo( |
| 23 | () => threadInfos.map(threadInfo => threadInfo.uiName), |
| 24 | [threadInfos], |
| 25 | ); |
| 26 | const resolvedEntityText = useResolvedEntityText(entityText, options); |
| 27 | invariant( |
| 28 | resolvedEntityText, |
| 29 | 'useResolvedEntityText only returns falsey when passed falsey', |
| 30 | ); |
| 31 | return React.useMemo( |
| 32 | () => |
| 33 | threadInfos.map((threadInfo, i) => { |
| 34 | if (typeof threadInfo.uiName === 'string') { |
| 35 | // Flow wants return { ...threadInfo, uiName: threadInfo.uiName } |
| 36 | // but that's wasteful and unneeded, so we any-cast here |
| 37 | return (threadInfo: any); |
| 38 | } |
| 39 | const resolvedThreadEntity = resolvedEntityText[i]; |
| 40 | return { |
| 41 | ...threadInfo, |
| 42 | uiName: entityTextToRawString([resolvedThreadEntity]), |
| 43 | }; |
| 44 | }), |
| 45 | [threadInfos, resolvedEntityText], |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | function useResolvedOptionalThreadInfos( |
| 50 | threadInfos: ?$ReadOnlyArray<ThreadInfo>, |
no test coverage detected