Page MenuHomePhabricator

D14016.id.diff
No OneTemporary

D14016.id.diff

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<Props> {
@@ -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 (
- <TouchableWithoutFeedback onPress={this.dismissKeyboard}>
+ <TouchableWithoutFeedback onPress={this.props.dismissKeyboard}>
<View style={this.props.styles.inputContainer}>
<AnimatedView style={this.props.expandoButtonsStyle}>
<View style={expandoButtonsViewStyle}>
{this.props.buttonsExpanded ? expandoButton : null}
<TouchableOpacity
- onPress={this.showMediaGallery}
+ onPress={this.props.showMediaGallery}
activeOpacity={0.4}
>
<AnimatedView style={this.props.cameraRollIconStyle}>
@@ -680,17 +668,6 @@
</TouchableWithoutFeedback>
);
}
-
- 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(
@@ -1417,6 +1394,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 (
<ChatInputBar
{...props}
@@ -1474,6 +1475,9 @@
isMessageEdited={isMessageEdited}
blockNavigation={blockNavigation}
onPressJoin={onPressJoin}
+ setIOSKeyboardHeight={setIOSKeyboardHeight}
+ showMediaGallery={showMediaGallery}
+ dismissKeyboard={dismissKeyboard}
/>
);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 1:38 PM (18 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2570920
Default Alt Text
D14016.id.diff (3 KB)

Event Timeline