From a291c78379f088583333976923793e33da3ad292 Mon Sep 17 00:00:00 2001 From: mashazyu Date: Mon, 15 Apr 2019 14:05:51 +0200 Subject: [PATCH 1/2] Delete password button bug fix --- components/settings/password/create.js | 2 +- components/settings/password/delete.js | 3 ++- components/settings/password/index.js | 14 ++++++++++++-- .../settings/password/show-backup-reminder.js | 6 ++++-- components/settings/password/update.js | 14 ++++++++++---- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/components/settings/password/create.js b/components/settings/password/create.js index aaa021d..9178312 100644 --- a/components/settings/password/create.js +++ b/components/settings/password/create.js @@ -19,7 +19,7 @@ export default class CreatePassword extends Component { } startSettingPassword = () => { - showBackUpReminder(this.toggleSettingPassword) + showBackUpReminder(this.toggleSettingPassword, () => {}) } render () { diff --git a/components/settings/password/delete.js b/components/settings/password/delete.js index b6435a0..7556a27 100644 --- a/components/settings/password/delete.js +++ b/components/settings/password/delete.js @@ -14,7 +14,7 @@ export default class DeletePassword extends Component { startConfirmWithPassword = () => { this.setState({ enteringCurrentPassword: true }) - this.props.onStartDeletingPassword() + this.props.onStartDelete() } startDeletePassword = async () => { @@ -23,6 +23,7 @@ export default class DeletePassword extends Component { cancelConfirmationWithPassword = () => { this.setState({ enteringCurrentPassword: false }) + this.props.onCancelDelete() } render() { diff --git a/components/settings/password/index.js b/components/settings/password/index.js index d4d0242..08406a4 100644 --- a/components/settings/password/index.js +++ b/components/settings/password/index.js @@ -24,10 +24,18 @@ export default class PasswordSetting extends Component { this.setState({ isChangingPassword: true }) } + onCancelChangingPassword = () => { + this.setState({ isChangingPassword: false }) + } + onDeletingPassword = () => { this.setState({ isDeletingPassword: true }) } + onCancelDeletingPassword = () => { + this.setState({ isDeletingPassword: false }) + } + render() { const { @@ -53,13 +61,15 @@ export default class PasswordSetting extends Component { { (isPasswordSet && !isDeletingPassword) && ( )} { (isPasswordSet && !isChangingPassword) && ( )} diff --git a/components/settings/password/show-backup-reminder.js b/components/settings/password/show-backup-reminder.js index f61e5a4..bf95646 100644 --- a/components/settings/password/show-backup-reminder.js +++ b/components/settings/password/show-backup-reminder.js @@ -2,7 +2,7 @@ import { Alert } from 'react-native' import { shared } from '../../../i18n/en/labels' import labels from '../../../i18n/en/settings' -export default function showBackUpReminder(okHandler, isDelete) { +export default function showBackUpReminder(okHandler, cancelHandler, isDelete) { let title, message if (isDelete) { title = labels.passwordSettings.deleteBackupReminderTitle @@ -17,10 +17,12 @@ export default function showBackUpReminder(okHandler, isDelete) { message, [{ text: shared.cancel, + onPress: cancelHandler, style: 'cancel' }, { text: shared.ok, onPress: okHandler - }] + }], + { onDismiss: cancelHandler } ) } \ No newline at end of file diff --git a/components/settings/password/update.js b/components/settings/password/update.js index e09433a..709427c 100644 --- a/components/settings/password/update.js +++ b/components/settings/password/update.js @@ -17,10 +17,15 @@ export default class ChangePassword extends Component { } startChangingPassword = () => { - showBackUpReminder(() => { - this.setState({ enteringCurrentPassword: true }) - }) - this.props.onStartChangingPassword() + showBackUpReminder( + this.startEnteringCurrentPassword, + this.cancelConfirmationWithPassword + ) + } + + startEnteringCurrentPassword = () => { + this.setState({ enteringCurrentPassword: true }) + this.props.onStartChange() } startEnteringNewPassword = () => { @@ -37,6 +42,7 @@ export default class ChangePassword extends Component { enteringNewPassword: false, enteringCurrentPassword: false }) + this.props.onCancelChange() } render() { From 31b428fa53a1c91c8c2f1e36c6e58c789229ba25 Mon Sep 17 00:00:00 2001 From: mashazyu Date: Mon, 15 Apr 2019 14:15:26 +0200 Subject: [PATCH 2/2] Add proptypes to DeletePassword, ChangePassword and ConfirmWithPassword components --- components/settings/password/delete.js | 7 +++++++ components/settings/password/update.js | 7 +++++++ components/settings/shared/confirm-with-password.js | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/components/settings/password/delete.js b/components/settings/password/delete.js index 7556a27..d034a73 100644 --- a/components/settings/password/delete.js +++ b/components/settings/password/delete.js @@ -1,4 +1,6 @@ import React, { Component } from 'react' +import PropTypes from 'prop-types' + import labels from '../../../i18n/en/settings' import { changeEncryptionAndRestartApp } from '../../../db' import ConfirmWithPassword from '../shared/confirm-with-password' @@ -45,4 +47,9 @@ export default class DeletePassword extends Component { ) } +} + +DeletePassword.propTypes = { + onStartDelete: PropTypes.func, + onCancelDelete: PropTypes.func } \ No newline at end of file diff --git a/components/settings/password/update.js b/components/settings/password/update.js index 709427c..447b9de 100644 --- a/components/settings/password/update.js +++ b/components/settings/password/update.js @@ -1,4 +1,6 @@ import React, { Component } from 'react' +import PropTypes from 'prop-types' + import settings from '../../../i18n/en/settings' import EnterNewPassword from './enter-new-password' import SettingsButton from '../shared/settings-button' @@ -77,4 +79,9 @@ export default class ChangePassword extends Component { ) } +} + +ChangePassword.propTypes = { + onStartChange: PropTypes.func, + onCancelChange: PropTypes.func } \ No newline at end of file diff --git a/components/settings/shared/confirm-with-password.js b/components/settings/shared/confirm-with-password.js index 0f34422..02d5600 100644 --- a/components/settings/shared/confirm-with-password.js +++ b/components/settings/shared/confirm-with-password.js @@ -1,4 +1,5 @@ import React, { Component } from 'react' +import PropTypes from 'prop-types' import { View, Alert } from 'react-native' import nodejs from 'nodejs-mobile-react-native' @@ -99,4 +100,9 @@ export default class ConfirmWithPassword extends Component { ) } +} + +ConfirmWithPassword.propTypes = { + onSuccess: PropTypes.func, + onCancel: PropTypes.func } \ No newline at end of file