From dad18219dd5b7f62ede1c8f6a338ba62a0c96866 Mon Sep 17 00:00:00 2001 From: IlarionHalushka Date: Fri, 21 Jun 2019 19:38:26 +0300 Subject: [PATCH] [BUG] Profile screen gets frozen when submitting invalid current password (#974) * fix 968: [BUG] Profile screen gets frozen when submitting invalid current password * revert changes to yarn.lock * remove unnecessary line * revert changes to yarn.lock * revert changes to yarn.lock --- app/utils/info.js | 2 +- app/views/ProfileView/index.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/utils/info.js b/app/utils/info.js index 90f77453..b2612cfb 100644 --- a/app/utils/info.js +++ b/app/utils/info.js @@ -29,4 +29,4 @@ export const Toast = React.forwardRef((props, ref) => ( opacity={0.8} /> )); -export const showErrorAlert = (message: string, title: string) => Alert.alert(title, message, [{ text: 'OK', onPress: () => {} }], { cancelable: true }); +export const showErrorAlert = (message, title, onPress = () => {}) => Alert.alert(title, message, [{ text: 'OK', onPress }], { cancelable: true }); diff --git a/app/views/ProfileView/index.js b/app/views/ProfileView/index.js index c86e25ea..0b11876e 100644 --- a/app/views/ProfileView/index.js +++ b/app/views/ProfileView/index.js @@ -151,8 +151,11 @@ export default class ProfileView extends React.Component { if (e.data && e.data.errorType === 'error-too-many-requests') { return showErrorAlert(e.data.error); } - showErrorAlert(I18n.t('There_was_an_error_while_action', { action: I18n.t(action) })); - // log(func, e); + showErrorAlert( + I18n.t('There_was_an_error_while_action', { action: I18n.t(action) }), + '', + () => this.setState({ showPasswordAlert: false }) + ); } submit = async() => { @@ -162,7 +165,7 @@ export default class ProfileView extends React.Component { return; } - this.setState({ saving: true, showPasswordAlert: false }); + this.setState({ saving: true }); const { name, username, email, newPassword, currentPassword, avatar, customFields @@ -218,7 +221,7 @@ export default class ProfileView extends React.Component { } else { setUser({ ...params }); } - this.setState({ saving: false }); + this.setState({ saving: false, showPasswordAlert: false }); this.toast.show(I18n.t('Profile_saved_successfully')); this.init(); }