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,39 +3,57 @@
[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
on-add-nickname (rn/use-callback #(rf/dispatch [:show-bottom-sheet public-key
{:content contact-request-state]
(fn [] [add-nickname/view])}])) :as contact} (rf/sub [:contacts/current-contact])
on-remove-nickname (rn/use-callback
(fn [] full-name (profile.utils/displayed-name contact)
(rf/dispatch [:hide-bottom-sheet]) on-add-nickname (rn/use-callback #(rf/dispatch [:show-bottom-sheet
(rf/dispatch [:toasts/upsert {:content
{:id :remove-nickname (fn [] [add-nickname/view])}]))
:type :positive on-remove-nickname (rn/use-callback
:text (i18n/label :t/nickname-removed)}]) (fn []
(rf/dispatch [:contacts/update-nickname public-key ""])) (rf/dispatch [:hide-bottom-sheet])
[public-key]) (rf/dispatch [:toasts/upsert
on-show-qr (rn/use-callback {:id :remove-nickname
(fn [] :type :positive
(rf/dispatch [:universal-links/generate-profile-url :text (i18n/label :t/nickname-removed)}])
{:public-key public-key (rf/dispatch [:contacts/update-nickname public-key ""]))
:on-success #(rf/dispatch [:open-modal [public-key])
:share-contact])}])) on-show-qr (rn/use-callback
[public-key]) (fn []
has-nickname? (rn/use-memo (fn [] (not (string/blank? nickname))) [nickname]) (rf/dispatch [:universal-links/generate-profile-url
on-share-profile (rn/use-callback {:public-key public-key
(fn [] :on-success #(rf/dispatch [:open-modal
(rf/dispatch [:universal-links/generate-profile-url :share-contact])}]))
{:public-key public-key [public-key])
:on-success #(rn/sharing {:message %})}])) has-nickname? (rn/use-memo (fn [] (not (string/blank? nickname))) [nickname])
[public-key])] on-share-profile (rn/use-callback
(fn []
(rf/dispatch [:universal-links/generate-profile-url
{:public-key public-key
:on-success #(rn/sharing {:message %})}]))
[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",