From d82bf5eeda47107b9f1f548dd339a7e142b035ac Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Wed, 22 Feb 2017 11:01:17 +0200 Subject: [PATCH] fix #821 --- .../chat/handlers/receive_message.cljs | 4 +-- src/status_im/handlers.cljs | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/status_im/chat/handlers/receive_message.cljs b/src/status_im/chat/handlers/receive_message.cljs index 73184efcfd..06118b443f 100644 --- a/src/status_im/chat/handlers/receive_message.cljs +++ b/src/status_im/chat/handlers/receive_message.cljs @@ -96,8 +96,8 @@ (register-handler :received-message-when-commands-loaded (u/side-effect! - (fn [db [_ chat-id message]] - (if (commands-loaded? db chat-id) + (fn [{:keys [status-node-started?] :as db} [_ chat-id message]] + (if (and status-node-started? (commands-loaded? db chat-id)) (dispatch [:received-message message]) (s/execute-later #(dispatch [:received-message-when-commands-loaded chat-id message]) diff --git a/src/status_im/handlers.cljs b/src/status_im/handlers.cljs index 7378d69b35..aae8015eac 100644 --- a/src/status_im/handlers.cljs +++ b/src/status_im/handlers.cljs @@ -27,7 +27,8 @@ [status-im.i18n :refer [label]] [status-im.constants :refer [console-chat-id]] [status-im.utils.ethereum-network :as enet] - [status-im.utils.instabug :as inst])) + [status-im.utils.instabug :as inst] + [status-im.utils.platform :as p])) ;; -- Common -------------------------------------------------------------- @@ -46,16 +47,14 @@ (assoc-in db [:animations k] v))) (register-handler :initialize-db - (fn [{:keys [status-module-initialized? network-status network]} _] + (fn [{:keys [status-module-initialized? status-node-started? + network-status network]} _] (data-store/init) - (cond-> (assoc app-db :current-account-id nil - :network-status network-status) - - status-module-initialized? - (assoc :status-module-initialized? true) - - true - (assoc :network (or network :testnet))))) + (assoc app-db :current-account-id nil + :network-status network-status + :status-module-initialized? (or p/ios? js/goog.DEBUG status-module-initialized?) + :status-node-started? status-node-started? + :network (or network :testnet)))) (register-handler :initialize-account-db (fn [db _] @@ -129,9 +128,9 @@ (case type "transaction.queued" (dispatch [:transaction-queued event]) "transaction.failed" (dispatch [:transaction-failed event]) - "node.started" (log/debug "Event *node.started* received") + "node.started" (dispatch [:status-node-started!]) "module.initialized" (dispatch [:status-module-initialized!]) - "local_storage.set" (dispatch [:set-local-storage event]) + "local_storage.set" (dispatch [:set-local-storage event]) (log/debug "Event " type " not handled")))))) (register-handler :status-module-initialized! @@ -141,6 +140,10 @@ (fn [db] (assoc db :status-module-initialized? true))) +(register-handler :status-node-started! + (fn [db] + (assoc db :status-node-started? true))) + (register-handler :crypt-initialized (u/side-effect! (fn [_ _]