From 3936d85c7737f0be1398b79a2f58a446f09f03a0 Mon Sep 17 00:00:00 2001 From: Andrey Shovkoplyas Date: Thu, 4 May 2017 16:37:51 +0300 Subject: [PATCH] fixes https://github.com/status-im/status-react/issues/1163 --- src/status_im/data_store/contacts.cljs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/status_im/data_store/contacts.cljs b/src/status_im/data_store/contacts.cljs index 5a7964a9e8..8dae1369dc 100644 --- a/src/status_im/data_store/contacts.cljs +++ b/src/status_im/data_store/contacts.cljs @@ -6,6 +6,13 @@ [[_ {:keys [name] :as command}]] [(keyword name) command]) +(defn- commands-map->commands-list + [commands-map] + (or (if (and commands-map (map? commands-map)) + (vals commands-map) + commands-map) + '())) + (defn get-all [] (map @@ -23,11 +30,13 @@ [{:keys [whisper-identity pending?] :as contact}] (let [{pending-db? :pending? :as contact-db} (data-store/get-by-id whisper-identity) - contact (assoc contact :pending? - (boolean (if contact-db - (if (nil? pending?) pending-db? pending?) - pending?)))] - (data-store/save contact (if contact-db true false)))) + contact' (-> contact + (assoc :pending? (boolean (if contact-db + (if (nil? pending?) pending-db? pending?) + pending?))) + (update :commands commands-map->commands-list) + (update :responses commands-map->commands-list))] + (data-store/save contact' (boolean contact-db)))) (defn save-all [contacts]