Skip to content

Commit cc75de0

Browse files
committed
mark untrusted option in contact screen
1 parent f9767e8 commit cc75de0

File tree

2 files changed

+57
-42
lines changed

2 files changed

+57
-42
lines changed

src/status_im/contexts/contact/trust/events.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@
4545
:on-error #(log/error "failed remove contact trust status" % contact-id)}]}))
4646

4747
(rf/reg-event-fx :contact/mark-as-untrusted-sheet
48-
(fn [_ {:keys [public-key primary-name] :as item}]
48+
(fn [_ [{:keys [public-key primary-name] :as item}]]
4949
{:dispatch
5050
[:show-bottom-sheet
5151
{:content (fn []
52+
(tap> item)
5253
[confirmation-drawer/confirmation-drawer
5354
{:title (i18n/label :t/mark-as-untrusted)
5455
:description (i18n/label :t/mark-as-untrusted-description

src/status_im/contexts/profile/contact/actions/view.cljs

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
(:require [clojure.string :as string]
33
[quo.core :as quo]
44
[react-native.core :as rn]
5-
[status-im.common.not-implemented :as not-implemented]
65
[status-im.constants :as constants]
76
[status-im.contexts.profile.contact.add-nickname.view :as add-nickname]
87
[status-im.contexts.profile.contact.block-contact.view :as block-contact]
98
[status-im.contexts.profile.utils :as profile.utils]
109
[utils.i18n :as i18n]
1110
[utils.re-frame :as rf]))
1211

12+
(defn hide-sheet-and-dispatch
13+
[event]
14+
(rf/dispatch [:hide-bottom-sheet])
15+
(rf/dispatch event))
16+
1317
(defn on-add-nickname
1418
[]
1519
(rf/dispatch [:show-bottom-sheet
@@ -25,43 +29,54 @@
2529
(defn view
2630
[]
2731
(let [{:keys [nickname public-key contact-request-state blocked? trust-status]
28-
:as contact} (rf/sub [:contacts/current-contact])
29-
full-name (profile.utils/displayed-name contact)
30-
on-remove-nickname (rn/use-callback
31-
(fn []
32-
(rf/dispatch [:hide-bottom-sheet])
33-
(rf/dispatch [:toasts/upsert
34-
{:id :remove-nickname
35-
:type :positive
36-
:text (i18n/label :t/nickname-removed)}])
37-
(rf/dispatch [:contacts/update-nickname public-key ""]))
38-
[public-key])
39-
on-show-qr (rn/use-callback
40-
(fn []
41-
(rf/dispatch [:universal-links/generate-profile-url
42-
{:public-key public-key
43-
:on-success #(rf/dispatch [:open-modal
44-
:screen/share-contact])}]))
45-
[public-key])
46-
has-nickname? (rn/use-memo (fn [] (not (string/blank? nickname))) [nickname])
47-
on-share-profile (rn/use-callback
48-
(fn []
49-
(rf/dispatch [:universal-links/generate-profile-url
50-
{:public-key public-key
51-
:on-success #(rf/dispatch [:open-share
52-
{:options {:message %}}])}]))
53-
[public-key])
54-
on-remove-contact (rn/use-callback
55-
(fn []
56-
(rf/dispatch [:hide-bottom-sheet])
57-
(rf/dispatch [:toasts/upsert
58-
{:id :remove-contact
59-
:type :positive
60-
:text (->> (i18n/label :t/removed-from-contacts)
61-
(string/lower-case)
62-
(str full-name " "))}])
63-
(rf/dispatch [:contact.ui/remove-contact-pressed contact]))
64-
[public-key full-name])]
32+
:as contact} (rf/sub [:contacts/current-contact])
33+
full-name (profile.utils/displayed-name contact)
34+
on-remove-nickname (rn/use-callback
35+
(fn []
36+
(rf/dispatch [:hide-bottom-sheet])
37+
(rf/dispatch [:toasts/upsert
38+
{:id :remove-nickname
39+
:type :positive
40+
:text (i18n/label :t/nickname-removed)}])
41+
(rf/dispatch [:contacts/update-nickname public-key ""]))
42+
[public-key])
43+
on-show-qr (rn/use-callback
44+
(fn []
45+
(rf/dispatch [:universal-links/generate-profile-url
46+
{:public-key public-key
47+
:on-success #(rf/dispatch [:open-modal
48+
:screen/share-contact])}]))
49+
[public-key])
50+
has-nickname? (rn/use-memo (fn [] (not (string/blank? nickname))) [nickname])
51+
on-share-profile (rn/use-callback
52+
(fn []
53+
(rf/dispatch [:universal-links/generate-profile-url
54+
{:public-key public-key
55+
:on-success #(rf/dispatch [:open-share
56+
{:options {:message %}}])}]))
57+
[public-key])
58+
untrustworthy? (rn/use-memo (fn []
59+
(= trust-status
60+
constants/contact-trust-status-untrustworthy))
61+
[trust-status])
62+
on-trust-mark-press (rn/use-callback
63+
(fn []
64+
(hide-sheet-and-dispatch
65+
(if untrustworthy?
66+
[:contact/remove-trust-status public-key full-name]
67+
[:contact/mark-as-untrusted-sheet contact])))
68+
[untrustworthy? contact])
69+
on-remove-contact (rn/use-callback
70+
(fn []
71+
(rf/dispatch [:hide-bottom-sheet])
72+
(rf/dispatch [:toasts/upsert
73+
{:id :remove-contact
74+
:type :positive
75+
:text (->> (i18n/label :t/removed-from-contacts)
76+
(string/lower-case)
77+
(str full-name " "))}])
78+
(rf/dispatch [:contact.ui/remove-contact-pressed contact]))
79+
[public-key full-name])]
6580
[quo/action-drawer
6681
[(concat
6782
[{:icon :i/edit
@@ -87,11 +102,10 @@
87102
:accessibility-label :remove-nickname
88103
:danger? true})
89104
{:icon :i/untrustworthy
90-
:label (i18n/label (if (= trust-status
91-
constants/contact-trust-status-untrustworthy)
105+
:label (i18n/label (if untrustworthy?
92106
:t/remove-untrusted-mark
93107
:t/mark-as-untrusted))
94-
:on-press not-implemented/alert
108+
:on-press on-trust-mark-press
95109
:accessibility-label :mark-as-untrusted
96110
:add-divider? (when-not has-nickname? true)
97111
:danger? true}

0 commit comments

Comments
 (0)