diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js --- a/native/chat/chat-input-bar.react.js +++ b/native/chat/chat-input-bar.react.js @@ -345,6 +345,9 @@ +isMessageEdited: (newText?: string) => boolean, +blockNavigation: () => void, +onPressJoin: () => void, + +setIOSKeyboardHeight: () => void, + +showMediaGallery: () => void, + +dismissKeyboard: () => void, }; class ChatInputBar extends React.PureComponent { @@ -411,7 +414,7 @@ this.props.hideButtons(); } else if (imageGalleryIsOpen && !imageGalleryWasOpen) { this.props.expandButtons(); - this.setIOSKeyboardHeight(); + this.props.setIOSKeyboardHeight(); } if ( @@ -422,21 +425,6 @@ } } - setIOSKeyboardHeight() { - if (Platform.OS !== 'ios') { - return; - } - const textInput = this.props.textInputRef.current; - if (!textInput) { - return; - } - const keyboardHeight = getKeyboardHeight(); - if (keyboardHeight === null || keyboardHeight === undefined) { - return; - } - TextInputKeyboardMangerIOS.setKeyboardHeight(textInput, keyboardHeight); - } - render(): React.Node { const isMember = viewerIsMember(this.props.threadInfo); let joinButton = null; @@ -613,13 +601,13 @@ expandoButtonsViewStyle.push({ display: 'none' }); } return ( - + {this.props.buttonsExpanded ? expandoButton : null} @@ -680,17 +668,6 @@ ); } - - showMediaGallery = () => { - const { keyboardState } = this.props; - invariant(keyboardState, 'keyboardState should be initialized'); - keyboardState.showMediaGallery(this.props.threadInfo); - }; - - dismissKeyboard = () => { - const { keyboardState } = this.props; - keyboardState && keyboardState.dismissKeyboard(); - }; } const joinThreadLoadingStatusSelector = createLoadingStatusSelector( @@ -1421,6 +1398,30 @@ void dispatchActionPromise(joinThreadActionTypes, joinAction()); }, [dispatchActionPromise, joinAction]); + const setIOSKeyboardHeight = React.useCallback(() => { + if (Platform.OS !== 'ios') { + return; + } + const textInput = textInputRef.current; + if (!textInput) { + return; + } + const keyboardHeight = getKeyboardHeight(); + if (keyboardHeight === null || keyboardHeight === undefined) { + return; + } + TextInputKeyboardMangerIOS.setKeyboardHeight(textInput, keyboardHeight); + }, []); + + const showMediaGallery = React.useCallback(() => { + invariant(keyboardState, 'keyboardState should be initialized'); + keyboardState.showMediaGallery(props.threadInfo); + }, [keyboardState, props.threadInfo]); + + const dismissKeyboard = React.useCallback(() => { + keyboardState?.dismissKeyboard(); + }, [keyboardState]); + return ( ); }