Merge pull request #311 from status-im/bug/#290

Wallet dapp is created before contacts sync 

Former-commit-id: 2435e2b893
This commit is contained in:
adrian-tiberius 2016-10-04 18:17:44 +03:00 committed by GitHub
commit 8f2c6d0b7c
4 changed files with 41 additions and 32 deletions

View File

@ -5,9 +5,10 @@
[status-im.utils.identicon :refer [identicon]] [status-im.utils.identicon :refer [identicon]]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[clojure.string :as str] [clojure.string :as str]
[status-im.utils.handlers :as u]
[status-im.protocol.core :as protocol])) [status-im.protocol.core :as protocol]))
(defn account-recovered [result password] (defn account-recovered [result]
(let [_ (log/debug result) (let [_ (log/debug result)
data (json->clj result) data (json->clj result)
public-key (:pubkey data) public-key (:pubkey data)
@ -18,7 +19,8 @@
:name address :name address
:photo-path (identicon public-key) :photo-path (identicon public-key)
:updates-public-key public :updates-public-key public
:updates-private-key private}] :updates-private-key private
:signed-up? true}]
(log/debug "account-recovered") (log/debug "account-recovered")
(when (not (str/blank? public-key)) (when (not (str/blank? public-key))
(do (do
@ -28,8 +30,10 @@
(dispatch [:navigate-back]))))) (dispatch [:navigate-back])))))
(defn recover-account (defn recover-account
[{:keys [recover] :as db} [_ passphrase password]] [_ [_ passphrase password]]
(status/recover-account passphrase password (fn [result] (account-recovered result password))) (status/recover-account
db) 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,7 +173,8 @@
(set-message-shown db chat-id message-id))) (set-message-shown db chat-id message-id)))
(defn init-console-chat (defn init-console-chat
[{:keys [chats] :as db} existing-account?] ([existing-account?] (init-console-chat {} existing-account?))
([{:keys [chats] :as db} existing-account?]
(let [new-chat sign-up-service/console-chat] (let [new-chat sign-up-service/console-chat]
(if (chats console-chat-id) (if (chats console-chat-id)
db db
@ -187,7 +188,7 @@
(assoc :new-chat new-chat) (assoc :new-chat new-chat)
(update :chats assoc console-chat-id new-chat) (update :chats assoc console-chat-id new-chat)
(update :chats-ids conj console-chat-id) (update :chats-ids conj console-chat-id)
(assoc :current-chat-id console-chat-id)))))) (assoc :current-chat-id console-chat-id)))))))
(register-handler :init-console-chat (register-handler :init-console-chat
(fn [db _] (fn [db _]
@ -215,7 +216,6 @@
db))) db)))
(register-handler :sign-up-confirm (register-handler :sign-up-confirm
(after #(dispatch [:init-wallet-chat]))
(u/side-effect! (u/side-effect!
(fn [_ [_ confirmation-code]] (fn [_ [_ confirmation-code]]
(server/sign-up-confirm confirmation-code sign-up-service/on-send-code-response)))) (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 ;TODO: check if its new account / signup status / create console chat
(register-handler :initialize-chats (register-handler :initialize-chats
(after #(dispatch [:load-unviewed-messages!])) [(after #(dispatch [:load-unviewed-messages!]))
(after #(dispatch [:init-wallet-chat]))]
((enrich initialize-chats) load-chats!)) ((enrich initialize-chats) load-chats!))
(defmethod nav/preload-data! :chat (defmethod nav/preload-data! :chat

View File

@ -5,7 +5,10 @@
(register-handler :init-wallet-chat (register-handler :init-wallet-chat
(u/side-effect! (u/side-effect!
(fn [] (fn [{:keys [chats]}]
(dispatch [:add-chat wallet-chat-id {:name "Wallet" (when-not (chats wallet-chat-id)
:dapp-url "http://127.0.0.1:3450"}])))) (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 [:initialize-db])
(dispatch [:load-accounts]) (dispatch [:load-accounts])
(dispatch [:init-console-chat]) (dispatch [:init-console-chat])
(dispatch [:init-wallet-chat])
(dispatch [:load-commands! console-chat-id])))) (dispatch [:load-commands! console-chat-id]))))
(register-handler :initialize-crypt (register-handler :initialize-crypt