[contacts]: added "remove contact" option in settings menu

Closes #10502
This commit is contained in:
Alexandra Betouni 2023-05-10 15:22:26 +03:00
parent 946534127a
commit 1f3a595116
4 changed files with 41 additions and 18 deletions

View File

@ -38,6 +38,7 @@ QtObject {
Global.openCommunityProfilePopupRequested.connect(openCommunityProfilePopup) Global.openCommunityProfilePopupRequested.connect(openCommunityProfilePopup)
Global.createCommunityPopupRequested.connect(openCreateCommunityPopup) Global.createCommunityPopupRequested.connect(openCreateCommunityPopup)
Global.importCommunityPopupRequested.connect(openImportCommunityPopup) Global.importCommunityPopupRequested.connect(openImportCommunityPopup)
Global.removeContactRequested.connect(openRemoveContactConfirmationPopup)
Global.openPopupRequested.connect(openPopup) Global.openPopupRequested.connect(openPopup)
} }
@ -198,7 +199,33 @@ QtObject {
openPopup(discordImportProgressDialog) openPopup(discordImportProgressDialog)
} }
function openRemoveContactConfirmationPopup(displayName, publicKey) {
openPopup(removeContactConfirmationDialog, {
displayName: displayName,
publicKey: publicKey
})
}
readonly property list<Component> _components: [ readonly property list<Component> _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 { Component {
id: contactVerificationRequestPopupComponent id: contactVerificationRequestPopupComponent
ContactVerificationRequestPopup { ContactVerificationRequestPopup {

View File

@ -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 { ConfirmationDialog {
id: removeVerificationConfirmationDialog id: removeVerificationConfirmationDialog
header.title: qsTr("Remove contact verification") header.title: qsTr("Remove contact verification")
@ -508,8 +492,8 @@ Pane {
type: StatusAction.Type.Danger type: StatusAction.Type.Danger
enabled: d.isContact && !d.isBlocked && d.contactRequestState !== Constants.ContactRequestState.Sent enabled: d.isContact && !d.isBlocked && d.contactRequestState !== Constants.ContactRequestState.Sent
onTriggered: { onTriggered: {
moreMenu.close() Global.removeContactRequested(root.mainDisplayName, root.publicKey);
removeContactConfirmationDialog.open() moreMenu.close();
} }
} }
StatusAction { StatusAction {

View File

@ -326,6 +326,17 @@ StatusMenu {
onTriggered: root.store.contactsStore.removeTrustStatus(root.selectedUserPublicKey) 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 { StatusAction {
id: blockMenuItem id: blockMenuItem
text: qsTr("Block User") text: qsTr("Block User")

View File

@ -38,6 +38,7 @@ QtObject {
signal openActivityCenterPopupRequested() signal openActivityCenterPopupRequested()
signal openSendIDRequestPopup(string publicKey, var cb) signal openSendIDRequestPopup(string publicKey, var cb)
signal openContactRequestPopup(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 openInviteFriendsToCommunityPopup(var community, var communitySectionModule, var cb)
signal openIncomingIDRequestPopup(string publicKey, var cb) signal openIncomingIDRequestPopup(string publicKey, var cb)
signal openOutgoingIDRequestPopup(string publicKey, var cb) signal openOutgoingIDRequestPopup(string publicKey, var cb)