Skip to content

Commit 43e1786

Browse files
committed
Use wakuext_sendContactRequest endpoint
1 parent 80bab6d commit 43e1786

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

src/status_im/add_new/core.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
(if-not validation-result
8383
(if new-contact?
8484
(rf/merge cofx
85-
(contact/add-contact chat-key nickname ens-name)
85+
(contact/send-contact-request chat-key)
8686
(navigation/navigate-to :contacts-list {}))
8787
(chat/start-chat cofx chat-key ens-name))
8888
{:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)

src/status_im/contact/chat.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(ns status-im.contact.chat
22
(:require [re-frame.core :as re-frame]
33
[status-im2.contexts.contacts.events :as contact]
4-
[utils.re-frame :as rf]
5-
[status-im2.navigation.events :as navigation]))
4+
[status-im2.navigation.events :as navigation]
5+
[utils.re-frame :as rf]))
66

77
(rf/defn contact-code-submitted
88
{:events [:contact.ui/contact-code-submitted]
@@ -11,7 +11,7 @@
1111
(let [{:keys [public-key ens-name]} new-identity]
1212
(rf/merge cofx
1313
#(if new-contact?
14-
(contact/add-contact % public-key nickname ens-name)
14+
(contact/send-contact-request % public-key)
1515
{:dispatch [:chat.ui/start-chat public-key ens-name]})
1616
#(when new-contact?
1717
(navigation/navigate-back %)))))

src/status_im/ui/screens/profile/contact/views.cljs

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@
3636
:disabled blocked?
3737
:accessibility-label :add-to-contacts-button
3838
:action (when-not blocked?
39-
#(re-frame/dispatch [:contact.ui/add-contact-pressed public-key
40-
nil ens-name]))}])
39+
(fn []
40+
(re-frame/dispatch [:contact.ui/send-contact-request
41+
public-key])))}])
4142
[{:label (i18n/label (if (or muted? blocked?) :t/unmute :t/mute))
4243
:icon :main-icons/notification
4344
:accessibility-label :mute-chat

src/status_im2/contexts/contacts/events.cljs

+14-10
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,20 @@
7575
[{:keys [db]} contacts]
7676
{:db (assoc db :contacts/contacts (into {} (map #(vector (:public-key %) %) contacts)))})
7777

78-
(rf/defn add-contact
79-
"Add a contact and set pending to false"
80-
{:events [:contact.ui/add-contact-pressed]}
81-
[{:keys [db]} public-key nickname ens-name]
82-
(when (not= (get-in db [:multiaccount :public-key]) public-key)
83-
{:json-rpc/call [{:method "wakuext_addContact"
84-
:params [{:id public-key :nickname nickname :ensName ens-name}]
85-
:js-response true
86-
:on-success #(rf/dispatch [:sanitize-messages-and-process-response %])
87-
:on-error #(log/error "failed to add contact" public-key %)}]}))
78+
(rf/defn send-contact-request
79+
{:events [:contact.ui/send-contact-request]}
80+
[{:keys [db]} id]
81+
(when (not= id (get-in db [:multiaccount :public-key]))
82+
{:json-rpc/call
83+
[{:method "wakuext_sendContactRequest"
84+
:js-response true
85+
:params [{:id id :message "Please add me to your contacts"}]
86+
:on-error (fn [error]
87+
(log/error "Failed to send contact request"
88+
{:error error
89+
:event :contact.ui/send-contact-request
90+
:id id}))
91+
:on-success #(rf/dispatch [:transport/message-sent %])}]}))
8892

8993
(rf/defn remove-contact
9094
"Remove a contact from current account's contact list"

0 commit comments

Comments
 (0)