fix #144 add-new-contact

This commit is contained in:
Roman Volosovskyi 2016-08-26 12:16:20 +03:00
parent 8483d444af
commit 8a39ac2718
2 changed files with 12 additions and 3 deletions

View File

@ -122,9 +122,15 @@
(assoc :new-contact-identity ""))) (assoc :new-contact-identity "")))
(register-handler :add-new-contact (register-handler :add-new-contact
(-> add-new-contact (u/side-effect!
((after save-contact)) (fn [_ [_ {:keys [whisper-identity] :as contact}]]
((after watch-contact)))) (when-not (contacts/get-contact whisper-identity)
(dispatch [::new-contact contact])))))
(register-handler ::new-contact
(-> add-new-contact
((after save-contact))
((after watch-contact))))
(defn set-contact-identity-from-qr (defn set-contact-identity-from-qr
[db [_ _ contact-identity]] [db [_ _ contact-identity]]

View File

@ -9,6 +9,9 @@
(r/sorted :name :asc) (r/sorted :name :asc)
r/collection->map)) r/collection->map))
(defn get-contact [id]
(r/get-one-by-field :account :contact :whisper-identity id))
(defn create-contact [{:keys [whisper-identity] :as contact}] (defn create-contact [{:keys [whisper-identity] :as contact}]
(let [contact-from-db (r/get-one-by-field :account :contact (let [contact-from-db (r/get-one-by-field :account :contact
:whisper-identity whisper-identity)] :whisper-identity whisper-identity)]