Page MenuHomePhabricator

D14008.id46112.diff
No OneTemporary

D14008.id46112.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
@@ -315,11 +315,10 @@
+setTextEdited: (edited: boolean) => void,
+buttonsExpanded: boolean,
+setButtonsExpanded: (expanded: boolean) => void,
+ +isExitingDuringEditModeRef: { current: boolean },
};
-type State = {
- +isExitingDuringEditMode: boolean,
-};
-class ChatInputBar extends React.PureComponent<Props, State> {
+
+class ChatInputBar extends React.PureComponent<Props> {
textInput: ?React.ElementRef<typeof TextInput>;
clearableTextInput: ?ClearableTextInput;
selectableTextInput: ?React.ElementRef<typeof SelectableTextInput>;
@@ -341,10 +340,6 @@
constructor(props: Props) {
super(props);
- this.state = {
- isExitingDuringEditMode: false,
- };
-
this.setUpActionIconAnimations();
this.setUpSendIconAnimations();
}
@@ -880,7 +875,7 @@
};
updateText = (text: string) => {
- if (this.state.isExitingDuringEditMode) {
+ if (this.props.isExitingDuringEditModeRef.current) {
return;
}
this.props.setText(text);
@@ -1008,7 +1003,7 @@
removeEditMode: RemoveEditMode = action => {
const { navigation } = this.props;
- if (!navigation || this.state.isExitingDuringEditMode) {
+ if (!navigation || this.props.isExitingDuringEditModeRef.current) {
return 'ignore_action';
}
if (!this.isMessageEdited()) {
@@ -1094,7 +1089,7 @@
};
onNavigationFocus = () => {
- this.setState({ isExitingDuringEditMode: false });
+ this.props.isExitingDuringEditModeRef.current = false;
};
onNavigationBlur = () => {
@@ -1102,7 +1097,8 @@
return;
}
this.props.setText(this.props.draft);
- this.setState({ isExitingDuringEditMode: true }, this.exitEditMode);
+ this.props.isExitingDuringEditModeRef.current = true;
+ this.exitEditMode();
};
onNavigationBeforeRemove = (e: {
@@ -1117,12 +1113,8 @@
e.preventDefault();
const saveExit = () => {
this.props.messageEditingContext?.setEditedMessage(null, () => {
- this.setState({ isExitingDuringEditMode: true }, () => {
- if (!this.props.navigation) {
- return;
- }
- this.props.navigation.dispatch(action);
- });
+ this.props.isExitingDuringEditModeRef.current = true;
+ this.props.navigation?.dispatch(action);
});
};
if (!this.isMessageEdited()) {
@@ -1353,6 +1345,8 @@
threadPermissions.JOIN_THREAD,
);
+ const isExitingDuringEditModeRef = React.useRef(false);
+
return (
<ChatInputBar
{...props}
@@ -1393,6 +1387,7 @@
setTextEdited={setTextEdited}
buttonsExpanded={buttonsExpanded}
setButtonsExpanded={setButtonsExpanded}
+ isExitingDuringEditModeRef={isExitingDuringEditModeRef}
/>
);
}

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 11:54 PM (18 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2697424
Default Alt Text
D14008.id46112.diff (2 KB)

Event Timeline