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