Skip to content

Commit 30f0b43

Browse files
authored
Various fixes for Contact Request flows (2nd attempt) (#15685)
- Make sure status-mobile works well with the upcoming status-go changes in PR status-im/status-go#3379. - Replace calls to `wakuext_addContact` with `wakuext_sendContactRequest`. This is what's been aligned with the desktop team, as we will go on to remove `wakuext_addContact` in the near future. Fixes #15679
1 parent 80bab6d commit 30f0b43

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
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

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
(ns status-im2.contexts.contacts.events
22
(:require
3-
[utils.re-frame :as rf]
4-
[taoensso.timbre :as log]
5-
[status-im.utils.types :as types]
63
[oops.core :as oops]
7-
[status-im2.constants :as constants]))
4+
[status-im.utils.types :as types]
5+
[status-im2.constants :as constants]
6+
[taoensso.timbre :as log]
7+
[utils.i18n :as i18n]
8+
[utils.re-frame :as rf]))
89

910
(defn <-rpc-js
1011
[^js js-contact]
@@ -75,16 +76,20 @@
7576
[{:keys [db]} contacts]
7677
{:db (assoc db :contacts/contacts (into {} (map #(vector (:public-key %) %) contacts)))})
7778

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 %)}]}))
79+
(rf/defn send-contact-request
80+
{:events [:contact.ui/send-contact-request]}
81+
[{:keys [db]} id]
82+
(when (not= id (get-in db [:multiaccount :public-key]))
83+
{:json-rpc/call
84+
[{:method "wakuext_sendContactRequest"
85+
:js-response true
86+
:params [{:id id :message (i18n/label :t/add-me-to-your-contacts)}]
87+
:on-error (fn [error]
88+
(log/error "Failed to send contact request"
89+
{:error error
90+
:event :contact.ui/send-contact-request
91+
:id id}))
92+
:on-success #(rf/dispatch [:transport/message-sent %])}]}))
8893

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

translations/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"advanced": "Advanced",
4646
"advanced-settings": "Advanced settings",
4747
"agree-by-continuing": "By continuing you agree\n to our ",
48+
"add-me-to-your-contacts": "Please add me to your contacts",
4849
"all": "All",
4950
"allow": "Allow",
5051
"allowing-authorizes-this-dapp": "Allowing authorizes this DApp to retrieve your wallet address and enable Web3",

0 commit comments

Comments
 (0)