Page MenuHomePhabricator

D7349.diff
No OneTemporary

D7349.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
@@ -14,6 +14,7 @@
TouchableWithoutFeedback,
NativeAppEventEmitter,
} from 'react-native';
+import Alert from 'react-native/Libraries/Alert/Alert.js';
import { TextInputKeyboardMangerIOS } from 'react-native-keyboard-input';
import Animated, { EasingNode } from 'react-native-reanimated';
import { useDispatch } from 'react-redux';
@@ -56,6 +57,7 @@
import type { LoadingStatus } from 'lib/types/loading-types.js';
import type { PhotoPaste } from 'lib/types/media-types.js';
import { messageTypes } from 'lib/types/message-types.js';
+import type { MessageInfo } from 'lib/types/message-types.js';
import type { Dispatch } from 'lib/types/redux-types.js';
import {
type ThreadInfo,
@@ -151,6 +153,7 @@
+mentionsCandidates: $ReadOnlyArray<RelativeMemberInfo>,
+parentThreadInfo: ?ThreadInfo,
+editedMessagePreview: ?MessagePreviewResult,
+ +editedMessageInfo: ?MessageInfo,
};
type State = {
+text: string,
@@ -790,8 +793,31 @@
return editState && editState.editedMessage !== null;
};
+ isMessageEdited = () => {
+ let text = this.state.text;
+ text = trimMessage(text);
+ const originalText = this.props.editedMessageInfo?.text;
+ return text !== originalText;
+ };
+
onPressExitEditMode = () => {
- this.exitEditMode();
+ if (!this.isMessageEdited()) {
+ this.exitEditMode();
+ return;
+ }
+ Alert.alert('Are you sure?', 'Your edits will be discarded.', [
+ {
+ text: 'Continue editing',
+ style: 'cancel',
+ },
+ {
+ text: 'Discard edit',
+ style: 'destructive',
+ onPress: () => {
+ this.exitEditMode();
+ },
+ },
+ ]);
};
exitEditMode = () => {
@@ -1063,6 +1089,7 @@
mentionsCandidates={mentionsCandidates}
parentThreadInfo={parentThreadInfo}
editedMessagePreview={editedMessagePreview}
+ editedMessageInfo={editedMessageInfo}
/>
);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 11:02 AM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2448268
Default Alt Text
D7349.diff (2 KB)

Event Timeline