fix account-recover screen errors

when typing a wrong recovery phrase or password, navigating back and
returning to account-recover screen, errors about recovery phrase and
password were not cleared

get rid of navigation/preload-data in the process as it is too clunky

TODO: eventually use screen-params in the future for screen related data
Signed-off-by: yenda <eric@status.im>
This commit is contained in:
yenda 2018-09-20 18:42:07 +02:00
parent 47b739b4df
commit 41d3fe17ea
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
5 changed files with 14 additions and 10 deletions

View File

@ -5,6 +5,7 @@
[status-im.accounts.db :as db]
[status-im.i18n :as i18n]
[status-im.native-module.core :as status]
[status-im.ui.screens.navigation :as navigation]
[status-im.utils.ethereum.mnemonic :as mnemonic]
[status-im.utils.handlers-macro :as handlers-macro]
[status-im.utils.identicon :as identicon]
@ -89,6 +90,11 @@
:confirm-button-text (i18n/label :recovery-confirm-phrase)
:on-accept #(re-frame/dispatch [:accounts.recover.ui/recover-account-confirmed])}}))))
(defn navigate-to-recover-account-screen [{:keys [db] :as cofx}]
(handlers-macro/merge-fx cofx
{:db (dissoc db :accounts/recover)}
(navigation/navigate-to-cofx :recover nil)))
(re-frame/reg-fx
:accounts.recover/recover-account
(fn [[masked-passphrase password]]

View File

@ -1,6 +1,5 @@
(ns status-im.events
(:require status-im.ui.screens.accounts.recover.navigation
[re-frame.core :as re-frame]
(:require [re-frame.core :as re-frame]
[status-im.accounts.core :as accounts]
[status-im.accounts.create.core :as accounts.create]
[status-im.accounts.login.core :as accounts.login]
@ -148,6 +147,11 @@
;; accounts recover module
(handlers/register-handler-fx
:accounts.recover.ui/recover-account-button-pressed
(fn [cofx _]
(accounts.recover/navigate-to-recover-account-screen cofx)))
(handlers/register-handler-fx
:accounts.recover.ui/passphrase-input-changed
(fn [cofx [_ recovery-phrase]]

View File

@ -1,6 +0,0 @@
(ns status-im.ui.screens.accounts.recover.navigation
(:require [status-im.ui.screens.navigation :as nav]))
(defmethod nav/preload-data! :recover
[db]
(update db :accounts/recover dissoc :password :passphrase :processing?))

View File

@ -45,7 +45,7 @@
[components.common/button {:on-press #(re-frame/dispatch [:accounts.create.ui/create-new-account-button-pressed])
:label (i18n/label :t/create-new-account)}]
[react/view styles/bottom-button-container
[components.common/button {:on-press #(re-frame/dispatch [:navigate-to :recover])
[components.common/button {:on-press #(re-frame/dispatch [:accounts.recover.ui/recover-account-button-pressed])
:label (i18n/label :t/add-existing-account)
:background? false}]]
[privacy-policy/privacy-policy-button]]]]))

View File

@ -23,7 +23,7 @@
:on-press #(re-frame/dispatch [:accounts.create.ui/create-new-account-button-pressed])
:label (i18n/label :t/create-account)}]
[react/view styles/bottom-button-container
[components.common/button {:on-press #(re-frame/dispatch [:navigate-to :recover])
[components.common/button {:on-press #(re-frame/dispatch [:accounts.recover.ui/recover-account-button-pressed])
:label (i18n/label :t/already-have-account)
:background? false}]]
[privacy-policy/privacy-policy-button]]])