Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3504205
D6103.id20430.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D6103.id20430.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
@@ -27,7 +27,6 @@
} from 'lib/utils/action-utils';
import Button from '../../components/button.react';
-import TextInput from '../../components/text-input.react';
import { clearThreadsActionType } from '../../navigation/action-types';
import {
NavContext,
@@ -58,20 +57,11 @@
// Redux dispatch functions
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
- +deleteThread: (
- threadID: string,
- currentAccountPassword: string,
- ) => Promise<LeaveThreadPayload>,
+ +deleteThread: (threadID: string) => Promise<LeaveThreadPayload>,
// withNavContext
+navDispatch: (action: NavAction) => void,
};
-type State = {
- +password: string,
-};
-class DeleteThread extends React.PureComponent<Props, State> {
- state: State = {
- password: '',
- };
+class DeleteThread extends React.PureComponent<Props> {
mounted = false;
passwordInput: ?React.ElementRef<typeof BaseTextInput>;
@@ -113,7 +103,6 @@
<Text style={this.props.styles.deleteText}>Delete chat</Text>
);
const threadInfo = DeleteThread.getThreadInfo(this.props);
- const { panelForegroundTertiaryLabel } = this.props.colors;
return (
<ScrollView
contentContainerStyle={this.props.styles.scrollViewContentContainer}
@@ -125,31 +114,9 @@
There is no way to reverse this.
</Text>
</View>
- <Text style={this.props.styles.header}>PASSWORD</Text>
- <View style={this.props.styles.section}>
- <TextInput
- style={this.props.styles.input}
- value={this.state.password}
- onChangeText={this.onChangePasswordText}
- placeholder="Password"
- placeholderTextColor={panelForegroundTertiaryLabel}
- secureTextEntry={true}
- textContentType="password"
- autoComplete="password"
- returnKeyType="go"
- onSubmitEditing={this.submitDeletion}
- ref={this.passwordInputRef}
- />
- </View>
<Button
onPress={this.submitDeletion}
- style={[
- this.props.styles.baseDeleteButton,
- this.state.password === ''
- ? this.props.styles.deleteButtonDisabled
- : this.props.styles.deleteButtonEnabled,
- ]}
- disabled={this.state.password === ''}
+ style={this.props.styles.deleteButton}
>
{buttonContent}
</Button>
@@ -157,10 +124,6 @@
);
}
- onChangePasswordText = (newPassword: string) => {
- this.guardedSetState({ password: newPassword });
- };
-
passwordInputRef = (
passwordInput: ?React.ElementRef<typeof BaseTextInput>,
) => {
@@ -173,10 +136,6 @@
};
submitDeletion = () => {
- if (this.state.password === '') {
- return;
- }
-
this.props.dispatchActionPromise(
deleteThreadActionTypes,
this.deleteThread(),
@@ -191,10 +150,7 @@
payload: { threadIDs: [threadInfo.id] },
});
try {
- const result = await this.props.deleteThread(
- threadInfo.id,
- this.state.password,
- );
+ const result = await this.props.deleteThread(threadInfo.id);
const invalidated = identifyInvalidatedThreads(
result.updatesResult.newUpdates,
);
@@ -204,46 +160,31 @@
});
return result;
} catch (e) {
- if (
- e.message === 'invalid_credentials' ||
- e.message === 'invalid_parameters'
- ) {
+ if (e.message === 'invalid_credentials') {
Alert.alert(
- 'Incorrect password',
- 'The password you entered is incorrect',
- [{ text: 'OK', onPress: this.onErrorAlertAcknowledged }],
+ 'Permission not granted',
+ 'You do not have permission to delete this thread',
+ [{ text: 'OK' }],
{ cancelable: false },
);
} else {
- Alert.alert(
- 'Unknown error',
- 'Uhh... try again?',
- [{ text: 'OK', onPress: this.onErrorAlertAcknowledged }],
- { cancelable: false },
- );
+ Alert.alert('Unknown error', 'Uhh... try again?', [{ text: 'OK' }], {
+ cancelable: false,
+ });
}
}
}
-
- onErrorAlertAcknowledged = () => {
- this.guardedSetState({ password: '' }, this.focusPasswordInput);
- };
}
const unboundStyles = {
- baseDeleteButton: {
+ deleteButton: {
+ backgroundColor: 'redButton',
borderRadius: 5,
flex: 1,
marginHorizontal: 24,
marginVertical: 12,
padding: 12,
},
- deleteButtonEnabled: {
- backgroundColor: 'redButton',
- },
- deleteButtonDisabled: {
- backgroundColor: 'disabledButton',
- },
deleteText: {
color: 'white',
fontSize: 18,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 7:43 AM (19 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2682587
Default Alt Text
D6103.id20430.diff (4 KB)
Attached To
Mode
D6103: Do not prompt for password when deleting thread
Attached
Detach File
Event Timeline
Log In to Comment