fix contacts loading

This commit is contained in:
Roman Volosovskyi 2016-06-02 14:23:28 +03:00
parent ba1d5d1c4e
commit 9ae6e752d8
3 changed files with 16 additions and 11 deletions

View File

@ -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]]

View File

@ -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]))

View File

@ -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!)