From 4f6eeea3b59f43950fabccc422efb0e6bc95b723 Mon Sep 17 00:00:00 2001 From: Eric Dvorsak Date: Mon, 14 May 2018 20:13:42 +0200 Subject: [PATCH] [fix] add public-key when adding contact Previously the public-key wasn't added when a contact was added until a contact-request-confirmation was received. This was causing contact-update not to be sent to contacts whose confirmation was not received yet when user was updating his profile. Signed-off-by: Eric Dvorsak --- src/status_im/ui/screens/contacts/core.cljs | 3 +-- src/status_im/ui/screens/contacts/events.cljs | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/status_im/ui/screens/contacts/core.cljs b/src/status_im/ui/screens/contacts/core.cljs index 3ba282bbb2..ff75d1b0c7 100644 --- a/src/status_im/ui/screens/contacts/core.cljs +++ b/src/status_im/ui/screens/contacts/core.cljs @@ -19,8 +19,7 @@ :fcm-token fcm-token :pending? true} chat-props {:name name - :chat-id public-key - :contact-info (prn-str contact-props)}] + :chat-id public-key}] (handlers-macro/merge-fx cofx {:db (update-in db [:contacts/contacts public-key] merge contact-props) diff --git a/src/status_im/ui/screens/contacts/events.cljs b/src/status_im/ui/screens/contacts/events.cljs index 22e2b6d75d..9bf1bd1ce7 100644 --- a/src/status_im/ui/screens/contacts/events.cljs +++ b/src/status_im/ui/screens/contacts/events.cljs @@ -35,7 +35,9 @@ {:db (update db :contacts/contacts #(merge contacts %))}))) (defn- add-new-contact [{:keys [whisper-identity] :as contact} {:keys [db]}] - (let [new-contact (assoc contact :pending? false)] + (let [new-contact (assoc contact + :pending? false + :public-key whisper-identity)] {:db (-> db (update-in [:contacts/contacts whisper-identity] merge new-contact) @@ -57,11 +59,9 @@ (transport/send (message.v1.contact/map->ContactRequest (own-info db)) whisper-identity cofx)))) (defn- build-contact [whisper-id {{:keys [chats] :contacts/keys [contacts]} :db}] - (-> (if-let [contact-info (get-in chats [whisper-id :contact-info])] - (reader/read-string contact-info) - (or (get contacts whisper-id) - (utils.contacts/whisper-id->new-contact whisper-id))) - (assoc :address (utils.contacts/public-key->address whisper-id)))) + (assoc (or (get contacts whisper-id) + (utils.contacts/whisper-id->new-contact whisper-id)) + :address (utils.contacts/public-key->address whisper-id))) (defn add-contact [whisper-id {:keys [db] :as cofx}] (let [contact (build-contact whisper-id cofx)]