|
46 | 46 | :on-error #(log/error "failed remove contact trust status" % contact-id)}]})) |
47 | 47 |
|
48 | 48 | (rf/reg-event-fx :contact/mark-as-untrusted-sheet |
49 | | - (fn [_ [{:keys [public-key] :as contact}]] |
50 | | - (let [name (profile.utils/displayed-name contact)] |
| 49 | + (fn [_ [{:keys [public-key contact-request-state] :as contact}]] |
| 50 | + (let [name (profile.utils/displayed-name contact) |
| 51 | + contact? (= contact-request-state |
| 52 | + constants/contact-request-state-mutual) |
| 53 | + request? (= contact-request-state |
| 54 | + constants/contact-request-state-received)] |
51 | 55 | {:dispatch |
52 | 56 | [:show-bottom-sheet |
53 | 57 | {:content (fn [] |
54 | 58 | [confirmation-drawer/confirmation-drawer |
55 | | - {:title (i18n/label :t/mark-as-untrusted) |
56 | | - :description (i18n/label :t/mark-as-untrusted-description |
57 | | - {:username (:primary-name contact)}) |
58 | | - :extra-action (fn [] |
59 | | - (rf/dispatch [:toasts/upsert |
60 | | - {:id :remove-contact |
61 | | - :type :positive |
62 | | - :text (->> (i18n/label |
63 | | - :t/removed-from-contacts) |
64 | | - (string/lower-case) |
65 | | - (str name " "))}]) |
66 | | - (rf/dispatch [:contact.ui/remove-contact-pressed contact])) |
67 | | - :extra-text (i18n/label :t/remove-contact) |
68 | | - :context contact |
69 | | - :accessibility-label :mark-as-untrustworthy |
70 | | - :button-text (i18n/label :t/mark-as-untrusted-button) |
71 | | - :on-press (fn [] |
72 | | - (rf/dispatch [:hide-bottom-sheet]) |
73 | | - (rf/dispatch |
74 | | - [:contact/mark-as-untrusted |
75 | | - public-key name]))}])}]}))) |
| 59 | + (merge {:title (i18n/label :t/mark-as-untrusted) |
| 60 | + :description (i18n/label :t/mark-as-untrusted-description |
| 61 | + {:username (:primary-name contact)}) |
| 62 | + :context contact |
| 63 | + :accessibility-label :mark-as-untrustworthy |
| 64 | + :button-text (i18n/label :t/mark-as-untrusted-button) |
| 65 | + :on-press (fn [] |
| 66 | + (rf/dispatch [:hide-bottom-sheet]) |
| 67 | + (rf/dispatch |
| 68 | + [:contact/mark-as-untrusted |
| 69 | + public-key name]))} |
| 70 | + (cond |
| 71 | + contact? |
| 72 | + {:extra-action (fn [] |
| 73 | + (rf/dispatch [:toasts/upsert |
| 74 | + {:id :remove-contact |
| 75 | + :type :positive |
| 76 | + :text (->> (i18n/label |
| 77 | + :t/removed-from-contacts) |
| 78 | + (string/lower-case) |
| 79 | + (str name " "))}]) |
| 80 | + (rf/dispatch [:contact.ui/remove-contact-pressed contact])) |
| 81 | + :extra-text (i18n/label :t/remove-contact)} |
| 82 | + request? |
| 83 | + {:extra-action (fn [] |
| 84 | + (rf/dispatch [:activity-center.contact-requests/decline |
| 85 | + public-key])) |
| 86 | + :extra-text (i18n/label :t/decline-contact-request)}))])}]}))) |
0 commit comments