Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3185865
D7349.id24957.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7349.id24957.diff
View Options
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';
@@ -57,6 +58,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,
@@ -152,6 +154,7 @@
+mentionsCandidates: $ReadOnlyArray<RelativeMemberInfo>,
+parentThreadInfo: ?ThreadInfo,
+messagePreviewResult: ?MessagePreviewResult,
+ +editedMessageInfo: ?MessageInfo,
};
type State = {
+text: string,
@@ -795,8 +798,30 @@
return editState && editState.editedMessageID !== 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',
+ onPress: () => {
+ this.exitEditMode();
+ },
+ },
+ ]);
};
exitEditMode = () => {
@@ -1068,6 +1093,7 @@
mentionsCandidates={mentionsCandidates}
parentThreadInfo={parentThreadInfo}
messagePreviewResult={messagePreviewResult}
+ editedMessageInfo={editedMessageInfo}
/>
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 1:48 PM (19 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2452675
Default Alt Text
D7349.id24957.diff (2 KB)
Attached To
Mode
D7349: [native] Add alert when exiting edit mode by clicking the exit button
Attached
Detach File
Event Timeline
Log In to Comment