This commit is contained in:
Roman Volosovskyi 2016-10-03 17:30:43 +03:00
parent 09e711eef6
commit c29cb2de5e
4 changed files with 41 additions and 32 deletions

View File

@ -5,20 +5,22 @@
[status-im.utils.identicon :refer [identicon]]
[taoensso.timbre :as log]
[clojure.string :as str]
[status-im.utils.handlers :as u]
[status-im.protocol.core :as protocol]))
(defn account-recovered [result password]
(let [_ (log/debug result)
(defn account-recovered [result]
(let [_ (log/debug result)
data (json->clj result)
public-key (:pubkey data)
address (:address data)
{:keys [public private]} (protocol/new-keypair!)
account {:public-key public-key
:address address
:name address
:photo-path (identicon public-key)
:updates-public-key public
:updates-private-key private}]
account {:public-key public-key
:address address
:name address
:photo-path (identicon public-key)
:updates-public-key public
:updates-private-key private
:signed-up? true}]
(log/debug "account-recovered")
(when (not (str/blank? public-key))
(do
@ -28,8 +30,10 @@
(dispatch [:navigate-back])))))
(defn recover-account
[{:keys [recover] :as db} [_ passphrase password]]
(status/recover-account passphrase password (fn [result] (account-recovered result password)))
db)
[_ [_ passphrase password]]
(status/recover-account
passphrase
password
(fn [result] (account-recovered result))))
(register-handler :recover-account recover-account)
(register-handler :recover-account (u/side-effect! recover-account))

View File

@ -173,21 +173,22 @@
(set-message-shown db chat-id message-id)))
(defn init-console-chat
[{:keys [chats] :as db} existing-account?]
(let [new-chat sign-up-service/console-chat]
(if (chats console-chat-id)
db
(do
(chats/create-chat new-chat)
(contacts/save-contacts [sign-up-service/console-contact])
(sign-up-service/intro)
(when existing-account?
(sign-up-service/start-signup))
(-> db
(assoc :new-chat new-chat)
(update :chats assoc console-chat-id new-chat)
(update :chats-ids conj console-chat-id)
(assoc :current-chat-id console-chat-id))))))
([existing-account?] (init-console-chat {} existing-account?))
([{:keys [chats] :as db} existing-account?]
(let [new-chat sign-up-service/console-chat]
(if (chats console-chat-id)
db
(do
(chats/create-chat new-chat)
(contacts/save-contacts [sign-up-service/console-contact])
(sign-up-service/intro)
(when existing-account?
(sign-up-service/start-signup))
(-> db
(assoc :new-chat new-chat)
(update :chats assoc console-chat-id new-chat)
(update :chats-ids conj console-chat-id)
(assoc :current-chat-id console-chat-id)))))))
(register-handler :init-console-chat
(fn [db _]
@ -215,7 +216,6 @@
db)))
(register-handler :sign-up-confirm
(after #(dispatch [:init-wallet-chat]))
(u/side-effect!
(fn [_ [_ confirmation-code]]
(server/sign-up-confirm confirmation-code sign-up-service/on-send-code-response))))
@ -265,7 +265,8 @@
;TODO: check if its new account / signup status / create console chat
(register-handler :initialize-chats
(after #(dispatch [:load-unviewed-messages!]))
[(after #(dispatch [:load-unviewed-messages!]))
(after #(dispatch [:init-wallet-chat]))]
((enrich initialize-chats) load-chats!))
(defmethod nav/preload-data! :chat

View File

@ -5,7 +5,10 @@
(register-handler :init-wallet-chat
(u/side-effect!
(fn []
(dispatch [:add-chat wallet-chat-id {:name "Wallet"
:dapp-url "http://127.0.0.1:3450"}]))))
(fn [{:keys [chats]}]
(when-not (chats wallet-chat-id)
(dispatch [:add-chat
wallet-chat-id
{:name "Wallet"
:dapp-url "http://127.0.0.1:3450"}])))))

View File

@ -70,6 +70,7 @@
(dispatch [:initialize-db])
(dispatch [:load-accounts])
(dispatch [:init-console-chat])
(dispatch [:init-wallet-chat])
(dispatch [:load-commands! console-chat-id]))))
(register-handler :initialize-crypt