mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-27 07:41:11 +00:00
[bug] check if account is new by checking accounts
previous behavior was using context (which screen we were on) to determine if account was new or not. in order to be able to have more straightforward automation this commit now checks the list of accounts to get that information which is more accurate and allows to login without navigating screens.
This commit is contained in:
parent
00132c5921
commit
7cc3918b8d
@ -97,20 +97,25 @@
|
||||
wrap-with-stop-node-fx)]
|
||||
(wrap-fn db' address password))))
|
||||
|
||||
(defn is-new-account?
|
||||
"checks if the account is in the accounts in the db"
|
||||
[{:accounts/keys [accounts]} address]
|
||||
(let [present? (set (keys accounts))]
|
||||
(not (present? address))))
|
||||
|
||||
(register-handler-fx
|
||||
:login-handler
|
||||
(fn [{db :db} [_ result address]]
|
||||
(let [data (json->clj result)
|
||||
(fn [{db :db} [_ login-result address]]
|
||||
(let [data (json->clj login-result)
|
||||
error (:error data)
|
||||
success (zero? (count error))
|
||||
db' (assoc-in db [:accounts/login :processing] false)]
|
||||
(log/debug "Logged in account: " result)
|
||||
(log/debug "Logging result: " login-result)
|
||||
(merge
|
||||
{:db (if success db' (assoc-in db' [:accounts/login :error] error))}
|
||||
(when success
|
||||
(let [is-login-screen? (= (:view-id db) :login)
|
||||
new-account? (not is-login-screen?)]
|
||||
(log/debug "Logged in: " (:view-id db) is-login-screen? new-account?)
|
||||
(let [new-account? (is-new-account? db address)]
|
||||
(log/debug "Logged in" (when new-account? " new account") ":" address)
|
||||
{::clear-web-data nil
|
||||
::change-account [address new-account?]}))))))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user