diff --git a/src/status_im/accounts/recover/handlers.cljs b/src/status_im/accounts/recover/handlers.cljs index 457189ed0d..8850fc05d6 100644 --- a/src/status_im/accounts/recover/handlers.cljs +++ b/src/status_im/accounts/recover/handlers.cljs @@ -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)) diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index 7fccafdda1..23850a59a5 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -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 diff --git a/src/status_im/chat/handlers/wallet_chat.cljs b/src/status_im/chat/handlers/wallet_chat.cljs index 40b964150a..02f7ef8196 100644 --- a/src/status_im/chat/handlers/wallet_chat.cljs +++ b/src/status_im/chat/handlers/wallet_chat.cljs @@ -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"}]))))) diff --git a/src/status_im/handlers.cljs b/src/status_im/handlers.cljs index 4bd8cca0fe..97a2c2e08d 100644 --- a/src/status_im/handlers.cljs +++ b/src/status_im/handlers.cljs @@ -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