Add :add-pending-contact-and-open-chat handler
This commit is contained in:
parent
3a65dcd3c2
commit
7012125024
|
@ -7,7 +7,7 @@
|
||||||
[status-im.protocol.core :as protocol]
|
[status-im.protocol.core :as protocol]
|
||||||
[status-im.utils.utils :refer [http-post]]
|
[status-im.utils.utils :refer [http-post]]
|
||||||
[status-im.utils.phone-number :refer [format-phone-number]]
|
[status-im.utils.phone-number :refer [format-phone-number]]
|
||||||
[status-im.utils.random :as random]
|
[status-im.utils.random :as random]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[cljs.reader :refer [read-string]]
|
[cljs.reader :refer [read-string]]
|
||||||
[status-im.utils.js-resources :as js-res]
|
[status-im.utils.js-resources :as js-res]
|
||||||
|
@ -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)]))))))
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@
|
||||||
:bot-url bot-url
|
:bot-url bot-url
|
||||||
:description description
|
:description description
|
||||||
:dapp-hash dapp-hash})
|
:dapp-hash dapp-hash})
|
||||||
all-default-contacts (conj default-contacts console-chat/contact)]
|
all-default-contacts (conj default-contacts console-chat/contact)]
|
||||||
[[:add-contacts all-default-contacts]]))
|
[[:add-contacts all-default-contacts]]))
|
||||||
|
|
||||||
(defn- prepare-add-chat-events [contacts default-contacts]
|
(defn- prepare-add-chat-events [contacts default-contacts]
|
||||||
|
@ -290,7 +290,7 @@
|
||||||
;; NOTE(oskarth): Overwriting default contacts here
|
;; NOTE(oskarth): Overwriting default contacts here
|
||||||
;;(remove #(identities (:whisper-identity %)))
|
;;(remove #(identities (:whisper-identity %)))
|
||||||
(map #(vector (:whisper-identity %) %))
|
(map #(vector (:whisper-identity %) %))
|
||||||
(into {}))
|
(into {}))
|
||||||
fx {:db (update db :contacts/contacts merge new-contacts')
|
fx {:db (update db :contacts/contacts merge new-contacts')
|
||||||
::save-contacts! (vals new-contacts')}]
|
::save-contacts! (vals new-contacts')}]
|
||||||
(transduce (map second)
|
(transduce (map second)
|
||||||
|
@ -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}]])})))
|
|
||||||
|
|
Loading…
Reference in New Issue