From 1f3a595116e09215c9d13a9363637ffa0c795a64 Mon Sep 17 00:00:00 2001 From: Alexandra Betouni <31625338+alexandraB99@users.noreply.github.com> Date: Wed, 10 May 2023 15:22:26 +0300 Subject: [PATCH] [contacts]: added "remove contact" option in settings menu Closes #10502 --- ui/app/mainui/Popups.qml | 27 +++++++++++++++++++ ui/imports/shared/views/ProfileDialogView.qml | 20 ++------------ .../views/chat/MessageContextMenuView.qml | 11 ++++++++ ui/imports/utils/Global.qml | 1 + 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/ui/app/mainui/Popups.qml b/ui/app/mainui/Popups.qml index 4f91e1615d..a83c9588f4 100644 --- a/ui/app/mainui/Popups.qml +++ b/ui/app/mainui/Popups.qml @@ -38,6 +38,7 @@ QtObject { Global.openCommunityProfilePopupRequested.connect(openCommunityProfilePopup) Global.createCommunityPopupRequested.connect(openCreateCommunityPopup) Global.importCommunityPopupRequested.connect(openImportCommunityPopup) + Global.removeContactRequested.connect(openRemoveContactConfirmationPopup) Global.openPopupRequested.connect(openPopup) } @@ -198,7 +199,33 @@ QtObject { openPopup(discordImportProgressDialog) } + function openRemoveContactConfirmationPopup(displayName, publicKey) { + openPopup(removeContactConfirmationDialog, { + displayName: displayName, + publicKey: publicKey + }) + } + readonly property list _components: [ + Component { + id: removeContactConfirmationDialog + ConfirmationDialog { + property string displayName + property string publicKey + header.title: qsTr("Remove '%1' as a contact").arg(displayName) + confirmationText: qsTr("This will mean that you and '%1' will no longer be able to send direct messages to each other. You will need to send them a new Contact Request in order to message again. All previous direct messages between you and '%1' will be retained in read-only mode.").arg(displayName) + showCancelButton: true + cancelBtnType: "" + onConfirmButtonClicked: { + rootStore.contactStore.removeContact(publicKey); + close(); + } + onCancelButtonClicked: { + close(); + } + onClosed: { destroy(); } + } + }, Component { id: contactVerificationRequestPopupComponent ContactVerificationRequestPopup { diff --git a/ui/imports/shared/views/ProfileDialogView.qml b/ui/imports/shared/views/ProfileDialogView.qml index 08493e2da8..94b0e3e0ae 100644 --- a/ui/imports/shared/views/ProfileDialogView.qml +++ b/ui/imports/shared/views/ProfileDialogView.qml @@ -255,22 +255,6 @@ Pane { } } - ConfirmationDialog { - id: removeContactConfirmationDialog - header.title: qsTr("Remove '%1' as a contact").arg(d.mainDisplayName) - confirmationText: qsTr("This will mean that you and '%1' will no longer be able to send direct messages to each other. You will need to send them a new Contact Request in order to message again. All previous direct messages between you and '%1' will be retained in read-only mode.").arg(d.mainDisplayName) - showCancelButton: true - cancelBtnType: "" - onConfirmButtonClicked: { - root.contactsStore.removeContact(root.publicKey) - close() - d.reload() - } - onCancelButtonClicked: { - removeContactConfirmationDialog.close(); - } - } - ConfirmationDialog { id: removeVerificationConfirmationDialog header.title: qsTr("Remove contact verification") @@ -508,8 +492,8 @@ Pane { type: StatusAction.Type.Danger enabled: d.isContact && !d.isBlocked && d.contactRequestState !== Constants.ContactRequestState.Sent onTriggered: { - moreMenu.close() - removeContactConfirmationDialog.open() + Global.removeContactRequested(root.mainDisplayName, root.publicKey); + moreMenu.close(); } } StatusAction { diff --git a/ui/imports/shared/views/chat/MessageContextMenuView.qml b/ui/imports/shared/views/chat/MessageContextMenuView.qml index cbda80f558..08e2a4ad19 100644 --- a/ui/imports/shared/views/chat/MessageContextMenuView.qml +++ b/ui/imports/shared/views/chat/MessageContextMenuView.qml @@ -326,6 +326,17 @@ StatusMenu { onTriggered: root.store.contactsStore.removeTrustStatus(root.selectedUserPublicKey) } + StatusAction { + text: qsTr("Remove Contact") + icon.name: "remove-contact" + type: StatusAction.Type.Danger + enabled: root.isContact && !root.isBlockedContact && !root.hasPendingContactRequest + onTriggered: { + Global.removeContactRequested(root.selectedUserDisplayName, root.selectedUserPublicKey); + root.close(); + } + } + StatusAction { id: blockMenuItem text: qsTr("Block User") diff --git a/ui/imports/utils/Global.qml b/ui/imports/utils/Global.qml index 6555f0ae3e..a3d352bd7b 100644 --- a/ui/imports/utils/Global.qml +++ b/ui/imports/utils/Global.qml @@ -38,6 +38,7 @@ QtObject { signal openActivityCenterPopupRequested() signal openSendIDRequestPopup(string publicKey, var cb) signal openContactRequestPopup(string publicKey, var cb) + signal removeContactRequested(string displayName, string publicKey) signal openInviteFriendsToCommunityPopup(var community, var communitySectionModule, var cb) signal openIncomingIDRequestPopup(string publicKey, var cb) signal openOutgoingIDRequestPopup(string publicKey, var cb)