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, + +deleteThread: (threadID: string) => Promise, // withNavContext +navDispatch: (action: NavAction) => void, }; -type State = { - +password: string, -}; -class DeleteThread extends React.PureComponent { - state: State = { - password: '', - }; +class DeleteThread extends React.PureComponent { mounted = false; passwordInput: ?React.ElementRef; @@ -113,7 +103,6 @@ Delete chat ); const threadInfo = DeleteThread.getThreadInfo(this.props); - const { panelForegroundTertiaryLabel } = this.props.colors; return ( - PASSWORD - - - @@ -157,10 +124,6 @@ ); } - onChangePasswordText = (newPassword: string) => { - this.guardedSetState({ password: newPassword }); - }; - passwordInputRef = ( passwordInput: ?React.ElementRef, ) => { @@ -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,