Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/containers/MessageActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ const MessageActions = React.memo(
};

const handleDelete = (message: any) => {
// TODO - migrate this function for ts when fix the lint erros
// @ts-ignore
showConfirmationAlert({
message: I18n.t('You_will_not_be_able_to_recover_this_message'),
confirmationText: I18n.t('Delete'),
Expand Down
25 changes: 0 additions & 25 deletions app/utils/info.js

This file was deleted.

41 changes: 41 additions & 0 deletions app/utils/info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Alert } from 'react-native';

import I18n from '../i18n';

export const showErrorAlert = (message: string, title = '', onPress = () => {}): void =>
Alert.alert(title, message, [{ text: 'OK', onPress }], { cancelable: true });

interface IShowConfirmationAlert {
title?: string;
message: string;
confirmationText: string;
dismissText?: string;
onPress: () => void;
onCancel?: () => void;
}

export const showConfirmationAlert = ({
title,
message,
confirmationText,
dismissText = I18n.t('Cancel'),
onPress,
onCancel
}: IShowConfirmationAlert): void =>
Alert.alert(
title || I18n.t('Are_you_sure_question_mark'),
message,
[
{
text: dismissText,
onPress: onCancel,
style: 'cancel'
},
{
text: confirmationText,
style: 'destructive',
onPress
}
],
{ cancelable: false }
);
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -41,14 +42,33 @@ const styles = StyleSheet.create({
}
});

class E2EEncryptionSecurityView extends React.Component {
state = { newPassword: '' };
interface IE2EEncryptionSecurityViewState {
newPassword: string;
}

interface IE2EEncryptionSecurityViewProps {
theme: string;
user: {
roles: string[];
id: string;
};
server: string;
encryptionEnabled: boolean;
logout(): void;
}

newPasswordInputRef = React.createRef();
class E2EEncryptionSecurityView extends React.Component<IE2EEncryptionSecurityViewProps, IE2EEncryptionSecurityViewState> {
private newPasswordInputRef: TextInputComp | undefined;

onChangePasswordText = debounce(text => this.setState({ newPassword: text }), 300);
static navigationOptions = (): StackNavigationOptions => ({
title: I18n.t('E2E_Encryption')
});

setNewPasswordRef = ref => (this.newPasswordInputRef = ref);
state = { newPassword: '' };

onChangePasswordText = debounce((text: string) => this.setState({ newPassword: text }), 300);

setNewPasswordRef = (ref: TextInputComp) => (this.newPasswordInputRef = ref);

changePassword = () => {
const { newPassword } = this.state;
Expand Down Expand Up @@ -170,29 +190,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));
4 changes: 1 addition & 3 deletions app/views/NewServerView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,10 @@ class NewServerView extends React.Component<INewServerView, IState> {
uriToPath = (uri: string) => uri.replace('file://', '');

handleRemove = () => {
// TODO: Remove ts-ignore when migrate the showConfirmationAlert
// @ts-ignore
showConfirmationAlert({
message: I18n.t('You_will_unset_a_certificate_for_this_server'),
confirmationText: I18n.t('Remove'),
onPress: this.setState({ certificate: null }) // We not need delete file from DocumentPicker because it is a temp file
onPress: () => this.setState({ certificate: null }) // We not need delete file from DocumentPicker because it is a temp file
});
};

Expand Down
2 changes: 0 additions & 2 deletions app/views/SettingsView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class SettingsView extends React.Component<IProps, any> {

handleLogout = () => {
logEvent(events.SE_LOG_OUT);
// @ts-ignore
showConfirmationAlert({
message: I18n.t('You_will_be_logged_out_of_this_application'),
confirmationText: I18n.t('Logout'),
Expand All @@ -97,7 +96,6 @@ class SettingsView extends React.Component<IProps, any> {

handleClearCache = () => {
logEvent(events.SE_CLEAR_LOCAL_SERVER_CACHE);
/* @ts-ignore */
showConfirmationAlert({
message: I18n.t('This_will_clear_all_your_offline_data'),
confirmationText: I18n.t('Clear'),
Expand Down