Add action to remove contact inside contact action menu (#19168)

* chore: add english translation for "Remove contact"

* feature: integrate remove-contact acton in contact-profile action menu
This commit is contained in:
Sean Hagstrom 2024-03-12 13:34:59 +00:00 committed by GitHub
parent 2931ae84ee
commit d4c8e48441
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 52 additions and 27 deletions

View File

@ -3,13 +3,20 @@
[quo.core :as quo] [quo.core :as quo]
[react-native.core :as rn] [react-native.core :as rn]
[status-im.common.not-implemented :as not-implemented] [status-im.common.not-implemented :as not-implemented]
[status-im.constants :as constants]
[status-im.contexts.profile.contact.add-nickname.view :as add-nickname] [status-im.contexts.profile.contact.add-nickname.view :as add-nickname]
[status-im.contexts.profile.utils :as profile.utils]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
(defn view (defn view
[] []
(let [{:keys [nickname public-key]} (rf/sub [:contacts/current-contact]) (let [{:keys [nickname
public-key
contact-request-state]
:as contact} (rf/sub [:contacts/current-contact])
full-name (profile.utils/displayed-name contact)
on-add-nickname (rn/use-callback #(rf/dispatch [:show-bottom-sheet on-add-nickname (rn/use-callback #(rf/dispatch [:show-bottom-sheet
{:content {:content
(fn [] [add-nickname/view])}])) (fn [] [add-nickname/view])}]))
@ -35,7 +42,18 @@
(rf/dispatch [:universal-links/generate-profile-url (rf/dispatch [:universal-links/generate-profile-url
{:public-key public-key {:public-key public-key
:on-success #(rn/sharing {:message %})}])) :on-success #(rn/sharing {:message %})}]))
[public-key])] [public-key])
on-remove-contact (rn/use-callback
(fn []
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:toasts/upsert
{:id :remove-contact
:type :positive
:text (->> (i18n/label :t/removed-from-contacts)
(string/lower-case)
(str full-name " "))}])
(rf/dispatch [:contact.ui/remove-contact-pressed contact]))
[public-key full-name])]
[quo/action-drawer [quo/action-drawer
[[{:icon :i/edit [[{:icon :i/edit
:label (if has-nickname? :label (if has-nickname?
@ -64,6 +82,12 @@
:accessibility-label :mark-untrustworthy :accessibility-label :mark-untrustworthy
:add-divider? (when-not has-nickname? true) :add-divider? (when-not has-nickname? true)
:danger? true} :danger? true}
(when (= constants/contact-request-state-mutual contact-request-state)
{:icon :i/remove-user
:label (i18n/label :t/remove-contact)
:on-press on-remove-contact
:accessibility-label :remove-contact
:danger? true})
{:icon :i/block {:icon :i/block
:label (i18n/label :t/block-user) :label (i18n/label :t/block-user)
:on-press not-implemented/alert :on-press not-implemented/alert

View File

@ -1224,6 +1224,7 @@
"remove": "Remove", "remove": "Remove",
"remove-from-chat": "Remove from chat", "remove-from-chat": "Remove from chat",
"remove-from-contacts": "Remove from contacts", "remove-from-contacts": "Remove from contacts",
"remove-contact": "Remove contact",
"remove-from-contacts-text": "By removing a user from your contact list you do not hide your wallet address from them", "remove-from-contacts-text": "By removing a user from your contact list you do not hide your wallet address from them",
"remove-network": "Remove network", "remove-network": "Remove network",
"remove-token": "Remove token", "remove-token": "Remove token",