From 9ae6e752d894170d65e8d8da813c5386796a3fe8 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Thu, 2 Jun 2016 14:23:28 +0300 Subject: [PATCH] fix contacts loading --- src/status_im/chat/handlers.cljs | 6 +++--- src/status_im/components/chat_icon/screen.cljs | 11 ++++++----- src/status_im/contacts/handlers.cljs | 10 +++++++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/status_im/chat/handlers.cljs b/src/status_im/chat/handlers.cljs index 011749f25f..0d0af3a2f3 100644 --- a/src/status_im/chat/handlers.cljs +++ b/src/status_im/chat/handlers.cljs @@ -230,9 +230,9 @@ (sign-up-service/stop-listening-confirmation-code-sms db))) (register-handler :sign-up-confirm - (fn [db [_ confirmation-code]] - (server/sign-up-confirm confirmation-code sign-up-service/on-send-code-response) - db)) + (u/side-effect! + (fn [_ [_ confirmation-code]] + (server/sign-up-confirm confirmation-code sign-up-service/on-send-code-response)))) (register-handler :set-signed-up (fn [db [_ signed-up]] diff --git a/src/status_im/components/chat_icon/screen.cljs b/src/status_im/components/chat_icon/screen.cljs index e44d334e33..0d93e38cbb 100644 --- a/src/status_im/components/chat_icon/screen.cljs +++ b/src/status_im/components/chat_icon/screen.cljs @@ -6,7 +6,8 @@ image icon]] [status-im.components.chat-icon.styles :as st] - [status-im.components.styles :refer [color-purple]])) + [status-im.components.styles :refer [color-purple]] + [clojure.string :as s])) (defn default-chat-icon [name styles] [view (:default-chat-icon styles) @@ -26,10 +27,10 @@ (defview chat-icon-view [chat-id group-chat name online styles] [photo-path [:chat-photo chat-id]] [view (:container styles) - (if (and photo-path (not (empty? photo-path))) + (if-not (s/blank? photo-path) [chat-icon photo-path styles] [default-chat-icon name styles]) - (when (not group-chat) + (when-not group-chat [contact-online online styles])]) (defn chat-icon-view-chat-list [chat-id group-chat name color online] @@ -80,7 +81,7 @@ [contact [:contact]] (let [;; TODO stub data online true - color color-purple] + color color-purple] [profile-icon-view (:photo-path contact) (:name contact) color online])) (defview my-profile-icon [] @@ -88,5 +89,5 @@ photo-path [:get :photo-path]] (let [;; TODO stub data online true - color color-purple] + color color-purple] [profile-icon-view photo-path name color online])) diff --git a/src/status_im/contacts/handlers.cljs b/src/status_im/contacts/handlers.cljs index b3320db158..acb9be9b6c 100644 --- a/src/status_im/contacts/handlers.cljs +++ b/src/status_im/contacts/handlers.cljs @@ -92,10 +92,14 @@ (defn add-new-contacts [{:keys [contacts] :as db} [_ new-contacts]] (let [identities (set (map :whisper-identity contacts)) - new-contacts' (remove #(identities (:whisper-identity %)) new-contacts)] + new-contacts' (->> new-contacts + (remove #(identities (:whisper-identity %))) + (map #(vector (:whisper-identity %) %)) + (into {}))] + (println new-contacts') (-> db - (update :contacts concat new-contacts') - (assoc :new-contacts new-contacts')))) + (update :contacts merge new-contacts') + (assoc :new-contacts (vals new-contacts'))))) (register-handler :add-contacts (after save-contacts!)