From 49c604acdd8bea8925c2f6ac961d5751f7ed40e3 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Mon, 5 Dec 2016 17:31:48 +0200 Subject: [PATCH] fix #538 --- src/status_im/chat/handlers.cljs | 10 +++++----- src/status_im/chat/sign_up.cljs | 11 +++++++---- src/status_im/components/status.cljs | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index fed6d2557c..3c0feebbad 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -257,15 +257,15 @@ (register-handler :account-generation-message (u/side-effect! - (fn [{:keys [chats]}] - (when (> 4 (count (get-in chats [console-chat-id :messages]))) + (fn [_] + (when (not (messages/get-by-id sign-up-service/passphraze-message-id)) (sign-up-service/account-generation-message))))) (register-handler :show-mnemonic (u/side-effect! - (fn [{:keys [chats]} [_ mnemonic]] - (let [messages-count (count (get-in chats [console-chat-id :messages]))] - (sign-up-service/passphrase-messages mnemonic messages-count))))) + (fn [_ [_ mnemonic]] + (let [crazy-math-message? (messages/get-by-id sign-up-service/crazy-math-message)] + (sign-up-service/passphrase-messages mnemonic crazy-math-message?))))) (register-handler :sign-up (after (fn [_ [_ phone-number]] diff --git a/src/status_im/chat/sign_up.cljs b/src/status_im/chat/sign_up.cljs index 7fd2f9ce41..0fd5e55b7c 100644 --- a/src/status_im/chat/sign_up.cljs +++ b/src/status_im/chat/sign_up.cljs @@ -112,10 +112,11 @@ :from console-chat-id :to "me"}])) +(def crazy-math-message "crazy-math-message") ;; -- Saving password ---------------------------------------- (defn account-generation-message [] (dispatch [:received-message - {:message-id (random/id) + {:message-id crazy-math-message :content (label :t/account-generation-message) :content-type text-content-type :outgoing false @@ -123,10 +124,12 @@ :from console-chat-id :to "me"}])) -(defn passphrase-messages [mnemonic messages-count] +(def passphraze-message-id "passphraze-message") + +(defn passphrase-messages [mnemonic crazy-math-message?] (dispatch [:received-message - {:message-id (random/id) - :content (if (> messages-count 3) + {:message-id passphraze-message-id + :content (if crazy-math-message? (label :t/phew-here-is-your-passphrase) (label :t/here-is-your-passphrase)) :content-type text-content-type diff --git a/src/status_im/components/status.cljs b/src/status_im/components/status.cljs index c091d50452..3059104c42 100644 --- a/src/status_im/components/status.cljs +++ b/src/status_im/components/status.cljs @@ -69,7 +69,7 @@ (defn create-account [password on-result] (when status (let [callback (fn [data] - (reset! account-creation? true) + (reset! account-creation? false) (on-result data))] (swap! account-creation? (fn [creation?]