File tree 9 files changed +39
-24
lines changed
ui/screens/profile/contact
9 files changed +39
-24
lines changed Original file line number Diff line number Diff line change 68
68
69
69
(fx/defn qr-code-handled
70
70
{:events [::qr-code-handled ]}
71
- [{:keys [db] :as cofx} {:keys [type public-key chat-id data]} {:keys [new-contact?] :as opts}]
71
+ [{:keys [db] :as cofx} {:keys [type public-key chat-id data ens-name ]} {:keys [new-contact?] :as opts}]
72
72
(let [public-key? (and (string? data)
73
73
(string/starts-with? data " 0x" ))
74
74
chat-key (cond
80
80
(if-not validation-result
81
81
(if new-contact?
82
82
(fx/merge cofx
83
- (contact/add-contact chat-key nil nil )
83
+ (contact/add-contact chat-key nil ens-name )
84
84
(navigation/navigate-to-cofx :contacts-list {}))
85
- (chat/start-chat cofx chat-key nil ))
85
+ (chat/start-chat cofx chat-key ens-name ))
86
86
{:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code )
87
87
:content (case validation-result
88
88
:invalid
Original file line number Diff line number Diff line change 387
387
388
388
(fx/defn show-profile
389
389
{:events [:chat.ui/show-profile ]}
390
- [{:keys [db] :as cofx} identity]
390
+ [{:keys [db] :as cofx} identity ens-name ]
391
391
(let [my-public-key (get-in db [:multiaccount :public-key ])]
392
392
(when (not= my-public-key identity)
393
393
(fx/merge
394
394
cofx
395
- {:db (assoc db :contacts/identity identity)}
395
+ {:db (-> db
396
+ (assoc :contacts/identity identity)
397
+ (assoc :contacts/ens-name ens-name))}
396
398
(start-profile-chat identity true )))))
397
399
398
400
(fx/defn clear-history-pressed
Original file line number Diff line number Diff line change 9
9
(fx/defn send-message-pressed
10
10
{:events [:contact.ui/send-message-pressed ]
11
11
:interceptors [(re-frame/inject-cofx :random-id-generator )]}
12
- [cofx {:keys [public-key]}]
12
+ [cofx {:keys [public-key ens-name ]}]
13
13
(fx/merge cofx
14
- {:dispatch-later [{:ms 1000 :dispatch [:chat.ui/start-chat public-key]}]}
14
+ {:dispatch-later [{:ms 1000 :dispatch [:chat.ui/start-chat public-key ens-name ]}]}
15
15
(notification-center/accept-all-activity-center-notifications-from-chat public-key)
16
16
(navigation/pop-to-root-tab :chat-stack )))
17
17
Original file line number Diff line number Diff line change 14
14
:identicon (identicon/identicon public-key)
15
15
:public-key public-key}))
16
16
17
+ (defn public-key-and-ens-name->new-contact [public-key ens-name]
18
+ (let [contact (public-key->new-contact public-key)]
19
+ (if ens-name (-> contact
20
+ (assoc :ens-name ens-name)
21
+ (assoc :ens-verified true )
22
+ (assoc :name ens-name))
23
+ contact)))
24
+
17
25
(defn public-key->contact
18
26
[contacts public-key]
19
27
(when public-key
Original file line number Diff line number Diff line change 55
55
(group-chats/create-from-link cofx params))
56
56
57
57
(fx/defn handle-view-profile
58
- [{:keys [db] :as cofx} {:keys [public-key]}]
58
+ [{:keys [db] :as cofx} {:keys [public-key ens-name ]}]
59
59
(let [own (new-chat.db/own-public-key? db public-key)]
60
60
(cond
61
61
(and public-key own)
62
- {:navigate- change-tab-fx :profile
62
+ {:change-tab-fx :profile
63
63
:pop-to-root-tab-fx :profile-stack }
64
64
65
65
(and public-key (not own))
66
66
(fx/merge cofx
67
- {:dispatch [:chat.ui/show-profile public-key]}
67
+ {:dispatch [:chat.ui/show-profile public-key ens-name ]}
68
68
(navigation/navigate-back ))
69
69
70
70
:else
Original file line number Diff line number Diff line change 62
62
(assoc (bidi/match-route routes uri) :uri uri :query-params (parse-query-params uri)))
63
63
64
64
(defn match-contact-async
65
- [chain {:keys [user-id]} callback]
65
+ [chain {:keys [user-id ens-name ]} callback]
66
66
(let [valid-key (and (spec/valid? :global/public-key user-id)
67
67
(not= user-id ens/default-key))]
68
68
(cond
69
- ( and valid-key)
69
+ valid-key
70
70
(callback {:type :contact
71
- :public-key user-id})
71
+ :public-key user-id
72
+ :ens-name ens-name})
72
73
73
74
(and (not valid-key) (string? user-id) (not (string/blank? user-id))
74
75
(not= user-id " 0x" ))
75
76
(let [chain-id (ethereum/chain-keyword->chain-id chain)
76
77
ens-name (stateofus/ens-name-parse user-id)
77
- on-success #(match-contact-async chain {:user-id %} callback)]
78
+ on-success #(match-contact-async chain {:user-id % :ens-name ens-name } callback)]
78
79
(ens/pubkey chain-id ens-name on-success))
79
80
80
81
:else
Original file line number Diff line number Diff line change 152
152
; ;contacts
153
153
(reg-root-key-sub ::contacts :contacts/contacts )
154
154
(reg-root-key-sub :contacts/current-contact-identity :contacts/identity )
155
+ (reg-root-key-sub :contacts/current-contact-ens-name :contacts/ens-name )
155
156
(reg-root-key-sub :contacts/new-identity :contacts/new-identity )
156
157
(reg-root-key-sub :group/selected-contacts :group/selected-contacts )
157
158
(reg-root-key-sub :contacts/blocked-set :contacts/blocked )
2309
2310
:contacts/current-contact
2310
2311
:<- [:contacts/contacts ]
2311
2312
:<- [:contacts/current-contact-identity ]
2312
- (fn [[contacts identity]]
2313
+ :<- [:contacts/current-contact-ens-name ]
2314
+ (fn [[contacts identity ens-name]]
2313
2315
(or (get contacts identity)
2314
- (-> identity
2315
- contact.db/public-key->new-contact
2316
- contact.db/enrich-contact))))
2316
+ (contact.db/enrich-contact
2317
+ (contact.db/public-key-and-ens-name->new-contact identity ens-name)))))
2317
2318
2318
2319
(re-frame/reg-sub
2319
2320
:contacts/contact-by-identity
Original file line number Diff line number Diff line change 24
24
(:require-macros [status-im.utils.views :as views]))
25
25
26
26
(defn actions
27
- [{:keys [public-key added? blocked?] :as contact} muted?]
27
+ [{:keys [public-key added? blocked? ens-name ] :as contact} muted?]
28
28
(concat [{:label (i18n/label :t/chat )
29
29
:icon :main-icons/message
30
- :action #(re-frame/dispatch [:contact.ui/send-message-pressed {:public-key public-key}])
30
+ :action #(re-frame/dispatch [:contact.ui/send-message-pressed {:public-key public-key
31
+ :ens-name ens-name}])
31
32
:accessibility-label :start-conversation-button }]
32
33
(if added?
33
34
[{:label (i18n/label :t/remove-from-contacts )
38
39
[{:label (i18n/label :t/add-to-contacts )
39
40
:icon :main-icons/add-contact
40
41
:accessibility-label :add-to-contacts-button
41
- :action #(re-frame/dispatch [:contact.ui/add-to-contact-pressed public-key])}])
42
+ :action #(re-frame/dispatch [:contact.ui/add-to-contact-pressed public-key nil ens-name ])}])
42
43
(when platform/ios?
43
44
[{:label (i18n/label (if (or muted? blocked?) :t/unmute :t/mute ))
44
45
:icon :main-icons/notification
Original file line number Diff line number Diff line change 80
80
(chat/start-public-chat cofx topic {})))
81
81
82
82
(fx/defn handle-view-profile
83
- [{:keys [db] :as cofx} {:keys [public-key]}]
83
+ [{:keys [db] :as cofx} {:keys [public-key ens-name ]}]
84
84
(log/info " universal-links: handling view profile" public-key)
85
85
(cond
86
86
(and public-key (new-chat.db/own-public-key? db public-key))
87
- {:navigate- change-tab-fx :profile
87
+ {:change-tab-fx :profile
88
88
:pop-to-root-tab-fx :profile-stack }
89
89
90
90
public-key
91
- (navigation/navigate-to-cofx (assoc-in cofx [:db :contacts/identity ] public-key)
91
+ (navigation/navigate-to-cofx (-> cofx
92
+ (assoc-in [:db :contacts/identity ] public-key)
93
+ (assoc-in [:db :contacts/ens-name ] ens-name))
92
94
:profile
93
95
{})))
94
96
You can’t perform that action at this time.
0 commit comments