feat(Profile flow): Remove a contact

- implement the new remove contact confirmation popup

Fixes #13521
This commit is contained in:
Lukáš Tinkl 2024-02-20 18:19:36 +01:00 committed by Lukáš Tinkl
parent f236782490
commit e46f6c311c
7 changed files with 85 additions and 27 deletions

View File

@ -220,14 +220,17 @@ SplitView {
function removeContact(publicKey) {
logs.logEvent("contactsStore::removeContact", ["publicKey"], arguments)
ctrlContactRequestState.currentIndex = ctrlContactRequestState.indexOfValue(Constants.ContactRequestState.None)
}
function acceptContactRequest(publicKey, contactRequestId) {
logs.logEvent("contactsStore::acceptContactRequest", ["publicKey, contactRequestId"], arguments)
ctrlContactRequestState.currentIndex = ctrlContactRequestState.indexOfValue(Constants.ContactRequestState.Mutual)
}
function dismissContactRequest(publicKey, contactRequestId) {
logs.logEvent("contactsStore::dismissContactRequest", ["publicKey, contactRequestId"], arguments)
ctrlContactRequestState.currentIndex = ctrlContactRequestState.indexOfValue(Constants.ContactRequestState.Dismissed)
}
function removeTrustStatus(publicKey) {

View File

@ -268,11 +268,8 @@ QtObject {
openPopup(discordImportProgressDialog, {importingSingleChannel: importingSingleChannel})
}
function openRemoveContactConfirmationPopup(displayName, publicKey) {
openPopup(removeContactConfirmationDialog, {
displayName: displayName,
publicKey: publicKey
})
function openRemoveContactConfirmationPopup(publicKey, contactDetails) {
openPopup(removeContactConfirmationDialog, {publicKey, contactDetails})
}
function openDeleteMessagePopup(messageId, messageStore) {
@ -346,21 +343,20 @@ QtObject {
readonly property list<Component> _components: [
Component {
id: removeContactConfirmationDialog
ConfirmationDialog {
property string displayName
property string publicKey
headerSettings.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();
RemoveContactPopup {
onAccepted: {
rootStore.contactStore.removeContact(publicKey)
if (removeIDVerification)
rootStore.contactStore.cancelVerificationRequest(publicKey)
if (markAsUntrusted) {
rootStore.contactStore.markUntrustworthy(publicKey)
Global.displaySuccessToastMessage(qsTr("%1 removed from contacts and marked as untrusted").arg(mainDisplayName))
} else {
Global.displaySuccessToastMessage(qsTr("%1 removed from contacts").arg(mainDisplayName))
}
close()
}
onCancelButtonClicked: {
close();
}
onClosed: { destroy(); }
onClosed: destroy()
}
},
Component {
@ -539,7 +535,7 @@ QtObject {
rootStore.contactStore.removeContact(publicKey)
Global.displaySuccessToastMessage(qsTr("%1 removed from contacts and marked as untrusted").arg(mainDisplayName))
} else {
Global.displayToastMessage(qsTr("%1 marked as untrusted").arg(mainDisplayName))
Global.displaySuccessToastMessage(qsTr("%1 marked as untrusted").arg(mainDisplayName))
}
close()
}

View File

@ -0,0 +1,62 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQml.Models 2.15
import StatusQ 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1
import utils 1.0
CommonContactDialog {
id: root
readonly property bool removeIDVerification: ctrlRemoveIDVerification.checked
readonly property bool markAsUntrusted: ctrlMarkAsUntrusted.checked
title: qsTr("Remove contact")
readonly property var d: QtObject {
id: d
readonly property int outgoingVerificationStatus: contactDetails.verificationStatus
readonly property int incomingVerificationStatus: contactDetails.incomingVerificationStatus
readonly property bool isVerificationRequestReceived: incomingVerificationStatus === Constants.verificationStatus.verifying ||
incomingVerificationStatus === Constants.verificationStatus.verified
readonly property bool isTrusted: outgoingVerificationStatus === Constants.verificationStatus.trusted ||
incomingVerificationStatus === Constants.verificationStatus.trusted
}
StatusBaseText {
Layout.fillWidth: true
Layout.bottomMargin: Style.current.halfPadding
text: qsTr("You and %1 will no longer be contacts").arg(mainDisplayName)
wrapMode: Text.WordWrap
}
StatusCheckBox {
id: ctrlRemoveIDVerification
visible: contactDetails.isContact && !d.isTrusted && d.isVerificationRequestReceived
checked: visible
enabled: false
text: qsTr("Remove ID verification")
}
StatusCheckBox {
id: ctrlMarkAsUntrusted
visible: contactDetails.trustStatus !== Constants.trustStatus.untrustworthy
text: qsTr("Mark %1 as untrusted").arg(mainDisplayName)
}
rightButtons: ObjectModel {
StatusFlatButton {
text: qsTr("Cancel")
onClicked: root.close()
}
StatusButton {
type: StatusBaseButton.Type.Danger
text: qsTr("Remove contact")
onClicked: root.accepted()
}
}
}

View File

@ -28,3 +28,4 @@ AlertPopup 1.0 AlertPopup.qml
ConfirmExternalLinkPopup 1.0 ConfirmExternalLinkPopup.qml
CommunityAssetsInfoPopup 1.0 CommunityAssetsInfoPopup.qml
MarkAsUntrustedPopup 1.0 MarkAsUntrustedPopup.qml
RemoveContactPopup 1.0 RemoveContactPopup.qml

View File

@ -80,7 +80,6 @@ Pane {
readonly property bool isTrusted: outgoingVerificationStatus === Constants.verificationStatus.trusted ||
incomingVerificationStatus === Constants.verificationStatus.trusted
readonly property bool isVerified: outgoingVerificationStatus === Constants.verificationStatus.verified
readonly property string linkToProfile: root.contactsStore.getLinkToProfile(root.publicKey)
@ -484,7 +483,7 @@ Pane {
type: StatusAction.Type.Danger
enabled: d.isContact && !d.isBlocked && d.contactRequestState !== Constants.ContactRequestState.Sent
onTriggered: {
Global.removeContactRequested(d.mainDisplayName, root.publicKey)
Global.removeContactRequested(root.publicKey, d.contactDetails)
}
}
StatusAction {

View File

@ -242,10 +242,7 @@ StatusMenu {
icon.name: "remove-contact"
type: StatusAction.Type.Danger
enabled: root.isContact && !root.isBlockedContact && !root.hasPendingContactRequest && !root.isBridgedAccount
onTriggered: {
Global.removeContactRequested(root.selectedUserDisplayName, root.selectedUserPublicKey)
root.close()
}
onTriggered: Global.removeContactRequested(root.selectedUserPublicKey, root.contactDetails)
}
StatusAction {

View File

@ -41,7 +41,7 @@ QtObject {
signal openSendIDRequestPopup(string publicKey, var contactDetails, var cb)
signal openContactRequestPopup(string publicKey, var contactDetails, var cb)
signal markAsUntrustedRequested(string publicKey, var contactDetails)
signal removeContactRequested(string displayName, string publicKey)
signal removeContactRequested(string publicKey, var contactDetails)
signal openInviteFriendsToCommunityPopup(var community, var communitySectionModule, var cb)
signal openIncomingIDRequestPopup(string publicKey, var cb)
signal openOutgoingIDRequestPopup(string publicKey, var cb)