From ec2d3a77a7a4d8deb7e9f01eaf1aafc7725c0d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Thor=C3=A9n?= Date: Sat, 21 Oct 2017 15:49:28 +0200 Subject: [PATCH] [FIX: #2262]: DApp description for default contacts (partial fix) Adds description to default contacts load. Partial fix in the sense that overwriting contacts don't work yet. Add description key to v16 migration. --- .../data_store/realm/schemas/account/v16/contact.cljs | 1 + src/status_im/ui/screens/contacts/db.cljs | 4 +++- src/status_im/ui/screens/contacts/events.cljs | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/status_im/data_store/realm/schemas/account/v16/contact.cljs b/src/status_im/data_store/realm/schemas/account/v16/contact.cljs index ad9e6304ad..3bcb185751 100644 --- a/src/status_im/data_store/realm/schemas/account/v16/contact.cljs +++ b/src/status_im/data_store/realm/schemas/account/v16/contact.cljs @@ -13,6 +13,7 @@ :mixable? {:type :bool :default false} :status {:type :string :optional true} :fcm-token {:type :string :optional true} + :description {:type :string :optional true} :public-key {:type :string :optional true} :private-key {:type :string diff --git a/src/status_im/ui/screens/contacts/db.cljs b/src/status_im/ui/screens/contacts/db.cljs index 3334bc77cb..61c8a28474 100644 --- a/src/status_im/ui/screens/contacts/db.cljs +++ b/src/status_im/ui/screens/contacts/db.cljs @@ -23,6 +23,7 @@ (spec/def :contact/photo-path (spec/nilable string?)) (spec/def :contact/status (spec/nilable string?)) (spec/def :contact/fcm-token (spec/nilable string?)) +(spec/def :contact/description (spec/nilable string?)) (spec/def :contact/last-updated (spec/nilable int?)) (spec/def :contact/last-online (spec/nilable int?)) @@ -67,7 +68,8 @@ :contact/responses :contact/debug? :contact/subscriptions - :contact/fcm-token])) + :contact/fcm-token + :contact/description])) ;;Contact list ui props (spec/def :contact-list-ui/edit? boolean?) diff --git a/src/status_im/ui/screens/contacts/events.cljs b/src/status_im/ui/screens/contacts/events.cljs index 54b5fcf297..cfb9288a9b 100644 --- a/src/status_im/ui/screens/contacts/events.cljs +++ b/src/status_im/ui/screens/contacts/events.cljs @@ -211,9 +211,12 @@ :timestamp (random/timestamp) :contacts (mapv #(hash-map :identity %) contacts)})]]) +;; TODO(oskarth): Consider getting rid of the :when so we can overwrite default +;; contacts with default_contacts.json This requires changing semantics of +;; update-pending-status (from :add-contacts handler) too. (defn- prepare-default-contacts-events [contacts default-contacts] [[:add-contacts - (for [[id {:keys [name photo-path public-key add-chat? pending? + (for [[id {:keys [name photo-path public-key add-chat? pending? description dapp? dapp-url dapp-hash bot-url unremovable? mixable?]}] default-contacts :let [id' (clojure.core/name id)] :when (not (get contacts id'))] @@ -228,6 +231,7 @@ :dapp? dapp? :dapp-url (:en dapp-url) :bot-url bot-url + :description description :dapp-hash dapp-hash})]]) (defn- prepare-add-chat-events [contacts default-contacts]