(props: Props)
| 30 | +route: NavigationRoute<'ThreadPickerModal'>, |
| 31 | }; |
| 32 | function ThreadPickerModal(props: Props): React.Node { |
| 33 | const { |
| 34 | navigation, |
| 35 | route: { |
| 36 | params: { dateString }, |
| 37 | }, |
| 38 | } = props; |
| 39 | |
| 40 | const viewerID = useSelector( |
| 41 | state => state.currentUserInfo && state.currentUserInfo.id, |
| 42 | ); |
| 43 | const dispatch = useDispatch(); |
| 44 | |
| 45 | const rootNavigatorContext = React.useContext(RootNavigatorContext); |
| 46 | const threadPicked = React.useCallback( |
| 47 | (threadID: string) => { |
| 48 | invariant( |
| 49 | dateString && viewerID && rootNavigatorContext, |
| 50 | 'inputs to threadPicked should be set', |
| 51 | ); |
| 52 | rootNavigatorContext.setKeyboardHandlingEnabled(false); |
| 53 | dispatch({ |
| 54 | type: createLocalEntryActionType, |
| 55 | payload: createLocalEntry(threadID, dateString, viewerID), |
| 56 | }); |
| 57 | }, |
| 58 | [rootNavigatorContext, dispatch, viewerID, dateString], |
| 59 | ); |
| 60 | |
| 61 | React.useEffect( |
| 62 | () => |
| 63 | navigation.addListener('blur', async () => { |
| 64 | await waitForInteractions(); |
| 65 | invariant( |
| 66 | rootNavigatorContext, |
| 67 | 'RootNavigatorContext should be set in onScreenBlur', |
| 68 | ); |
| 69 | rootNavigatorContext.setKeyboardHandlingEnabled(true); |
| 70 | }), |
| 71 | [navigation, rootNavigatorContext], |
| 72 | ); |
| 73 | |
| 74 | const index = useGlobalThreadSearchIndex(); |
| 75 | const onScreenThreadInfos = useOnScreenEntryEditableThreadInfos(); |
| 76 | return ( |
| 77 | <Modal> |
| 78 | <ThreadList |
| 79 | threadInfos={onScreenThreadInfos} |
| 80 | onSelect={threadPicked} |
| 81 | itemStyle={styles.threadListItem} |
| 82 | searchIndex={index} |
| 83 | /> |
| 84 | </Modal> |
| 85 | ); |
| 86 | } |
| 87 | |
| 88 | const styles = StyleSheet.create({ |
| 89 | threadListItem: { |
nothing calls this directly
no test coverage detected