diff --git a/app/stacks/InsideStack.tsx b/app/stacks/InsideStack.tsx
index 21b2004d8..544edb32d 100644
--- a/app/stacks/InsideStack.tsx
+++ b/app/stacks/InsideStack.tsx
@@ -277,11 +277,7 @@ const E2ESaveYourPasswordStackNavigator = () => {
-
+
);
diff --git a/app/stacks/MasterDetailStack/index.tsx b/app/stacks/MasterDetailStack/index.tsx
index bba752d80..e36b81ac9 100644
--- a/app/stacks/MasterDetailStack/index.tsx
+++ b/app/stacks/MasterDetailStack/index.tsx
@@ -195,11 +195,7 @@ const ModalStackNavigator = React.memo(({ navigation }: INavigation) => {
-
+
diff --git a/app/views/E2ESaveYourPasswordView.tsx b/app/views/E2ESaveYourPasswordView.tsx
index 6426ec2ca..ff6409b2d 100644
--- a/app/views/E2ESaveYourPasswordView.tsx
+++ b/app/views/E2ESaveYourPasswordView.tsx
@@ -1,7 +1,9 @@
-import React from 'react';
-import { ScrollView, StyleSheet, Text, View } from 'react-native';
import Clipboard from '@react-native-clipboard/clipboard';
-import { connect } from 'react-redux';
+import React, { useEffect, useLayoutEffect, useState } from 'react';
+import { ScrollView, StyleSheet, Text, View } from 'react-native';
+import { useDispatch } from 'react-redux';
+import { StackActions, useNavigation } from '@react-navigation/native';
+import { StackNavigationProp } from '@react-navigation/stack';
import { encryptionSetBanner } from '../actions/encryption';
import Button from '../containers/Button';
@@ -9,15 +11,15 @@ import * as HeaderButton from '../containers/HeaderButton';
import SafeAreaView from '../containers/SafeAreaView';
import StatusBar from '../containers/StatusBar';
import { LISTENER } from '../containers/Toast';
-import { IApplicationState, IBaseScreen } from '../definitions';
import I18n from '../i18n';
-import { E2E_RANDOM_PASSWORD_KEY, themes } from '../lib/constants';
-import UserPreferences from '../lib/methods/userPreferences';
-import { E2ESaveYourPasswordStackParamList } from '../stacks/types';
-import { withTheme } from '../theme';
+import { E2E_RANDOM_PASSWORD_KEY } from '../lib/constants';
+import { useAppSelector } from '../lib/hooks';
import EventEmitter from '../lib/methods/helpers/events';
import { events, logEvent } from '../lib/methods/helpers/log';
import scrollPersistTaps from '../lib/methods/helpers/scrollPersistTaps';
+import UserPreferences from '../lib/methods/userPreferences';
+import { E2ESaveYourPasswordStackParamList } from '../stacks/types';
+import { useTheme } from '../theme';
import sharedStyles from './Styles';
const styles = StyleSheet.create({
@@ -54,123 +56,78 @@ const styles = StyleSheet.create({
}
});
-interface IE2ESaveYourPasswordViewState {
- password: string | null;
-}
+const E2ESaveYourPasswordView = () => {
+ const server = useAppSelector(state => state.server.server);
+ const navigation = useNavigation>();
+ const dispatch = useDispatch();
+ const [password, setPassword] = useState('');
+ const { colors } = useTheme();
-interface IE2ESaveYourPasswordViewProps extends IBaseScreen {
- server: string;
-}
+ useLayoutEffect(() => {
+ navigation.setOptions({
+ title: I18n.t('Save_Your_E2E_Password'),
+ headerLeft: () =>
+ });
+ }, [navigation]);
-class E2ESaveYourPasswordView extends React.Component {
- private mounted: boolean;
-
- static navigationOptions = ({ navigation }: Pick) => ({
- headerLeft: () => ,
- title: I18n.t('Save_Your_E2E_Password')
- });
-
- constructor(props: IE2ESaveYourPasswordViewProps) {
- super(props);
- this.mounted = false;
- this.state = { password: '' };
- this.init();
- }
-
- componentDidMount() {
- this.mounted = true;
- }
-
- init = () => {
- const { server } = this.props;
- try {
- // Set stored password on local state
+ useEffect(() => {
+ const init = () => {
const password = UserPreferences.getString(`${server}-${E2E_RANDOM_PASSWORD_KEY}`);
- if (this.mounted) {
- this.setState({ password });
- } else {
- // @ts-ignore
- this.state.password = password;
- }
- } catch {
- // Do nothing
- }
- };
+ if (password) setPassword(password);
+ };
+ init();
+ }, []);
- onSaved = () => {
+ const onSaved = () => {
logEvent(events.E2E_SAVE_PW_SAVED);
- const { navigation, server, dispatch } = this.props;
- // Remove stored password
UserPreferences.removeItem(`${server}-${E2E_RANDOM_PASSWORD_KEY}`);
- // Hide encryption banner
dispatch(encryptionSetBanner());
- navigation.pop();
+ navigation.dispatch(StackActions.pop());
};
- onCopy = () => {
+ const onCopy = () => {
logEvent(events.E2E_SAVE_PW_COPY);
- const { password } = this.state;
if (password) {
Clipboard.setString(password);
EventEmitter.emit(LISTENER, { message: I18n.t('Copied_to_clipboard') });
}
};
- onHowItWorks = () => {
+ const onHowItWorks = () => {
logEvent(events.E2E_SAVE_PW_HOW_IT_WORKS);
- const { navigation } = this.props;
navigation.navigate('E2EHowItWorksView');
};
- render() {
- const { password } = this.state;
- const { theme } = this.props;
-
- return (
-
-
-
-
-
- {I18n.t('Save_Your_Encryption_Password_warning')}
-
-
- {I18n.t('Your_password_is')}
- {password}
-
-
- {I18n.t('Save_Your_Encryption_Password_info')}
+ return (
+
+
+
+
+ {I18n.t('Save_Your_Encryption_Password_warning')}
+
+ {I18n.t('Your_password_is')}
+ {password}
-
-
-
- );
- }
-}
+ {I18n.t('Save_Your_Encryption_Password_info')}
+
+
+
+
+
+ );
+};
-const mapStateToProps = (state: IApplicationState) => ({
- server: state.server.server
-});
-
-export default connect(mapStateToProps)(withTheme(E2ESaveYourPasswordView));
+export default E2ESaveYourPasswordView;