Chore: Migrate E2EEncryptionSecurityView to Typescript (#3489)

Co-authored-by: AlexAlexandre <alexalexandrejr@gmail.com>
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Reinaldo Neto 2021-11-17 17:02:57 -03:00 committed by GitHub
parent 945fe235cd
commit a22e9593b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 24 deletions

View File

@ -1,7 +1,8 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import PropTypes from 'prop-types';
import { StyleSheet, Text, View, TextInput as TextInputComp } from 'react-native';
import { StackNavigationOptions } from '@react-navigation/stack';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
import StatusBar from '../containers/StatusBar';
import * as List from '../containers/List';
@ -41,20 +42,41 @@ const styles = StyleSheet.create({
}
});
class E2EEncryptionSecurityView extends React.Component {
interface IE2EEncryptionSecurityViewState {
newPassword: string;
}
interface IE2EEncryptionSecurityViewProps {
theme: string;
user: {
roles: string[];
id: string;
};
server: string;
encryptionEnabled: boolean;
logout(): void;
}
class E2EEncryptionSecurityView extends React.Component<IE2EEncryptionSecurityViewProps, IE2EEncryptionSecurityViewState> {
private newPasswordInputRef: any = React.createRef();
static navigationOptions = (): StackNavigationOptions => ({
title: I18n.t('E2E_Encryption')
});
state = { newPassword: '' };
newPasswordInputRef = React.createRef();
onChangePasswordText = debounce((text: string) => this.setState({ newPassword: text }), 300);
onChangePasswordText = debounce(text => this.setState({ newPassword: text }), 300);
setNewPasswordRef = ref => (this.newPasswordInputRef = ref);
setNewPasswordRef = (ref: TextInputComp) => (this.newPasswordInputRef = ref);
changePassword = () => {
const { newPassword } = this.state;
if (!newPassword.trim()) {
return;
}
// TODO: Remove ts-ignore when migrate the showConfirmationAlert
// @ts-ignore
showConfirmationAlert({
title: I18n.t('Are_you_sure_question_mark'),
message: I18n.t('E2E_encryption_change_password_message'),
@ -76,6 +98,8 @@ class E2EEncryptionSecurityView extends React.Component {
};
resetOwnKey = () => {
// TODO: Remove ts-ignore when migrate the showConfirmationAlert
// @ts-ignore
showConfirmationAlert({
title: I18n.t('Are_you_sure_question_mark'),
message: I18n.t('E2E_encryption_reset_message'),
@ -170,29 +194,14 @@ class E2EEncryptionSecurityView extends React.Component {
}
}
const mapStateToProps = state => ({
const mapStateToProps = (state: any) => ({
server: state.server.server,
user: getUserSelector(state),
encryptionEnabled: state.encryption.enabled
});
const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch: Dispatch) => ({
logout: () => dispatch(logoutAction(true))
});
E2EEncryptionSecurityView.navigationOptions = () => ({
title: I18n.t('E2E_Encryption')
});
E2EEncryptionSecurityView.propTypes = {
theme: PropTypes.string,
user: PropTypes.shape({
roles: PropTypes.array,
id: PropTypes.string
}),
server: PropTypes.string,
encryptionEnabled: PropTypes.bool,
logout: PropTypes.func
};
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(E2EEncryptionSecurityView));