[fix 5705] fix crash when tapping sign in twice in account recovery

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
yenda 2018-09-19 21:11:11 +02:00 committed by Igor Mandrigin
parent 0658cdbdfa
commit 195b70fcdd
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
2 changed files with 16 additions and 14 deletions

View File

@ -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

View File

@ -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])}]])])))