From 195b70fcdd43311b51f46a3caf4e41dbc2bba703 Mon Sep 17 00:00:00 2001 From: yenda Date: Wed, 19 Sep 2018 21:11:11 +0200 Subject: [PATCH] [fix 5705] fix crash when tapping sign in twice in account recovery Signed-off-by: Igor Mandrigin --- src/status_im/accounts/recover/core.cljs | 18 ++++++++++-------- .../ui/screens/accounts/recover/views.cljs | 12 ++++++------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/status_im/accounts/recover/core.cljs b/src/status_im/accounts/recover/core.cljs index 1d9e270387..fe5f89538c 100644 --- a/src/status_im/accounts/recover/core.cljs +++ b/src/status_im/accounts/recover/core.cljs @@ -70,7 +70,7 @@ (defn on-account-recovered [result password {:keys [db] :as cofx}] (let [data (types/json->clj result)] (handlers-macro/merge-fx cofx - {:db (assoc-in db [:accounts/recover :processing?] false)} + {:db (dissoc db :accounts/recover)} (validate-recover-result data password)))) (defn recover-account [{:keys [db]}] @@ -79,13 +79,15 @@ :accounts.recover/recover-account [(security/mask-data passphrase) password]})) (defn recover-account-with-checks [{:keys [db] :as cofx}] - (let [{:keys [passphrase]} (:accounts/recover db)] - (if (mnemonic/status-generated-phrase? passphrase) - (recover-account cofx) - {:ui/show-confirmation {:title (i18n/label :recovery-typo-dialog-title) - :content (i18n/label :recovery-typo-dialog-description) - :confirm-button-text (i18n/label :recovery-confirm-phrase) - :on-accept #(re-frame/dispatch [:accounts.recover.ui/recover-account-confirmed])}}))) + (let [{:keys [passphrase processing?]} (:accounts/recover db)] + (when-not processing? + (if (mnemonic/status-generated-phrase? passphrase) + (recover-account cofx) + {:ui/show-confirmation + {:title (i18n/label :recovery-typo-dialog-title) + :content (i18n/label :recovery-typo-dialog-description) + :confirm-button-text (i18n/label :recovery-confirm-phrase) + :on-accept #(re-frame/dispatch [:accounts.recover.ui/recover-account-confirmed])}})))) (re-frame/reg-fx :accounts.recover/recover-account diff --git a/src/status_im/ui/screens/accounts/recover/views.cljs b/src/status_im/ui/screens/accounts/recover/views.cljs index df04b42e88..b591268d2b 100644 --- a/src/status_im/ui/screens/accounts/recover/views.cljs +++ b/src/status_im/ui/screens/accounts/recover/views.cljs @@ -47,9 +47,10 @@ :error (when error (i18n/label error))}]]) (defview recover [] - (letsubs [{:keys [passphrase password processing passphrase-valid? password-valid? - password-error passphrase-error passphrase-warning processing?]} [:get-recover-account]] - (let [valid-form? (and password-valid? passphrase-valid?)] + (letsubs [recovered-account [:get-recover-account]] + (let [{:keys [passphrase password processing passphrase-valid? password-valid? + password-error passphrase-error passphrase-warning processing?]} recovered-account + valid-form? (and password-valid? passphrase-valid?)] [react/keyboard-avoiding-view {:style styles/screen-container} [status-bar/status-bar] [toolbar/toolbar nil toolbar/default-nav-back @@ -69,6 +70,5 @@ [components.common/bottom-button {:forward? true :label (i18n/label :t/sign-in) - :disabled? (or processing? (not valid-form?)) - :on-press (utils.core/wrap-call-once! - #(re-frame/dispatch [:accounts.recover.ui/sign-in-button-pressed]))}]])]))) + :disabled? (or (not recovered-account) processing? (not valid-form?)) + :on-press #(re-frame/dispatch [:accounts.recover.ui/sign-in-button-pressed])}]])])))