Add :add-pending-contact-and-open-chat handler

This commit is contained in:
Andrea Maria Piana 2018-01-14 16:45:07 +00:00 committed by Eric Dvorsak
parent 3a65dcd3c2
commit 7012125024
No known key found for this signature in database
GPG Key ID: 932AC1CE5F05DE0C
1 changed files with 15 additions and 10 deletions

View File

@ -156,7 +156,7 @@
:photo-path (identicon whisper-identity) :photo-path (identicon whisper-identity)
:whisper-identity whisper-identity}] :whisper-identity whisper-identity}]
(if (contacts/exists? whisper-identity) (if (contacts/exists? whisper-identity)
(dispatch [:add-pending-contact whisper-identity]) (dispatch [:add-pending-contact-and-open-chat whisper-identity])
(dispatch [:add-new-contact-and-open-chat contact]))) (dispatch [:add-new-contact-and-open-chat contact])))
(dispatch [:set :contacts/new-public-key-error (label :t/unknown-address)])))))) (dispatch [:set :contacts/new-public-key-error (label :t/unknown-address)]))))))
@ -348,6 +348,12 @@
[:watch-contact contact'] [:watch-contact contact']
[:discoveries-send-portions chat-or-whisper-id]]}))) [:discoveries-send-portions chat-or-whisper-id]]})))
(register-handler-fx
:add-pending-contact-and-open-chat
(fn [_ [_ whisper-id]]
{:dispatch-n [[:add-pending-contact whisper-id]
[:start-chat whisper-id {:navigation-replace? true}]]}))
(register-handler-db (register-handler-db
:set-contact-identity-from-qr :set-contact-identity-from-qr
(fn [db [_ _ contact-identity]] (fn [db [_ _ contact-identity]]
@ -439,9 +445,8 @@
(fn [{:keys [db]} [_ id]] (fn [{:keys [db]} [_ id]]
(if (spec/valid? :global/address id) (if (spec/valid? :global/address id)
{::request-contact-by-address id} {::request-contact-by-address id}
{:dispatch-n (if (get-in db [:contacts/contacts id]) {:dispatch (if (get-in db [:contacts/contacts id])
[[:add-pending-contact id] [:add-pending-contact-and-open-chat id]
[:start-chat id {:navigation-replace? true}]] [:add-new-contact-and-open-chat {:name (generate-gfy id)
[[:add-new-contact-and-open-chat {:name (generate-gfy id)
:photo-path (identicon id) :photo-path (identicon id)
:whisper-identity id}]])}))) :whisper-identity id}])})))