Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2907424
D8590.id29519.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D8590.id29519.diff
View Options
diff --git a/native/chat/settings/delete-thread.react.js b/native/chat/settings/delete-thread.react.js
--- a/native/chat/settings/delete-thread.react.js
+++ b/native/chat/settings/delete-thread.react.js
@@ -6,7 +6,6 @@
Text,
View,
TextInput as BaseTextInput,
- Alert,
ActivityIndicator,
} from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
@@ -16,8 +15,14 @@
deleteThread,
} from 'lib/actions/thread-actions.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
-import { threadInfoSelector } from 'lib/selectors/thread-selectors.js';
-import { identifyInvalidatedThreads } from 'lib/shared/thread-utils.js';
+import {
+ threadInfoSelector,
+ containedThreadInfos,
+} from 'lib/selectors/thread-selectors.js';
+import {
+ identifyInvalidatedThreads,
+ getThreadsToDeleteText,
+} from 'lib/shared/thread-utils.js';
import type { LoadingStatus } from 'lib/types/loading-types.js';
import type {
ThreadInfo,
@@ -41,6 +46,7 @@
import { useSelector } from '../../redux/redux-utils.js';
import { type Colors, useColors, useStyles } from '../../themes/colors.js';
import type { GlobalTheme } from '../../types/themes.js';
+import Alert from '../../utils/alert.js';
import type { ChatNavigationProp } from '../chat.react.js';
export type DeleteThreadParams = {
@@ -55,6 +61,7 @@
...BaseProps,
// Redux state
+threadInfo: ResolvedThreadInfo,
+ +shouldUseDeleteConfirmationAlert: boolean,
+loadingStatus: LoadingStatus,
+activeTheme: ?GlobalTheme,
+colors: Colors,
@@ -124,13 +131,31 @@
this.passwordInput.focus();
};
- submitDeletion = () => {
+ dispatchDeleteThreadAction = () => {
this.props.dispatchActionPromise(
deleteThreadActionTypes,
this.deleteThread(),
);
};
+ submitDeletion = () => {
+ if (!this.props.shouldUseDeleteConfirmationAlert) {
+ this.dispatchDeleteThreadAction();
+ return;
+ }
+ Alert.alert(
+ 'Warning',
+ `${getThreadsToDeleteText(
+ this.props.threadInfo,
+ )} will also be permanently deleted.`,
+ [
+ { text: 'Cancel', style: 'cancel' },
+ { text: 'Continue', onPress: this.dispatchDeleteThreadAction },
+ ],
+ { cancelable: false },
+ );
+ };
+
async deleteThread() {
const { threadInfo, navDispatch } = this.props;
navDispatch({
@@ -230,6 +255,9 @@
const reduxThreadInfo = useSelector(
state => threadInfoSelector(state)[threadID],
);
+ const reduxContainedThreadInfos = useSelector(
+ state => containedThreadInfos(state)[threadID],
+ );
const { setParams } = props.navigation;
React.useEffect(() => {
@@ -253,10 +281,14 @@
invariant(navContext, 'NavContext should be set in DeleteThread');
const navDispatch = navContext.dispatch;
+ const shouldUseDeleteConfirmationAlert =
+ reduxContainedThreadInfos && reduxContainedThreadInfos.length > 0;
+
return (
<DeleteThread
{...props}
threadInfo={resolvedThreadInfo}
+ shouldUseDeleteConfirmationAlert={shouldUseDeleteConfirmationAlert}
loadingStatus={loadingStatus}
activeTheme={activeTheme}
colors={colors}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 7, 11:15 AM (21 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2254099
Default Alt Text
D8590.id29519.diff (3 KB)
Attached To
Mode
D8590: [native] Warn the user when deleting a chat that has contained chats
Attached
Detach File
Event Timeline
Log In to Comment