feat(ActivityCenter) Outgoing contact request notification text fixes

Close #8388
This commit is contained in:
MishkaRogachev 2022-12-22 17:26:27 +04:00 committed by Mikhail Rogachev
parent 76b6fba5ad
commit 97436b6e26
2 changed files with 67 additions and 23 deletions

View File

@ -9,6 +9,7 @@ import shared.panels 1.0
Item {
id: root
property bool isOutgoingRequest: false
property bool pending: false
property bool accepted: false
property bool dismissed: false
@ -27,10 +28,12 @@ Item {
id: textItem
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
visible: !pending
visible: !buttons.visible
text: {
if (root.accepted) {
return qsTr("Accepted")
} else if (root.pending) {
return qsTr("Pending")
} else if (root.dismissed) {
return blocked ? qsTr("Declined & Blocked") : qsTr("Declined")
}
@ -48,7 +51,7 @@ Item {
AcceptRejectOptionsButtonsPanel {
id: buttons
visible: pending
visible: pending && !isOutgoingRequest
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
onAcceptClicked: root.acceptClicked()

View File

@ -15,41 +15,82 @@ import "../popups"
ActivityNotificationMessage {
id: root
readonly property bool isOutgoingRequest: notification && notification.message.amISender
readonly property string contactId: notification ? isOutgoingRequest ? notification.chatId : notification.author : ""
readonly property var contactDetails: notification ? Utils.getContactDetailsAsJson(contactId, false) : null
readonly property bool pending: notification && notification.message.contactRequestState === Constants.contactRequestStatePending
readonly property bool accepted: notification && notification.message.contactRequestState === Constants.contactRequestStateAccepted
readonly property bool dismissed: notification && notification.message.contactRequestState === Constants.contactRequestStateDismissed
maximumLineCount: 5
ctaComponent: ContactRequestCta {
readonly property string senderId: notification ? notification.message.senderId : ""
readonly property var contactDetails: notification ?
Utils.getContactDetailsAsJson(notification.message.senderId, false) :
null
messageDetails.messageText: {
if (isOutgoingRequest && contactDetails) {
const status = accepted ? qsTr("accepted") : dismissed ? qsTr("dismissed") : qsTr("recieved")
return qsTr("%1 %2 your contact request").arg(contactDetails.displayName).arg(status)
}
pending: notification && notification.message.contactRequestState === Constants.contactRequestStatePending
accepted: notification && notification.message.contactRequestState === Constants.contactRequestStateAccepted
dismissed: notification && notification.message.contactRequestState === Constants.contactRequestStateDismissed
if (!isOutgoingRequest && notification) {
return notification.message.messageText
}
return ""
}
// TODO: unify with verification requests PR: https://github.com/status-im/status-desktop/pull/8246
messageDetails.amISender: false
messageDetails.sender.id: contactId
messageDetails.sender.displayName: contactDetails ? contactDetails.displayName : ""
messageDetails.sender.secondaryName: contactDetails ? contactDetails.localNickname : ""
messageDetails.sender.trustIndicator: contactDetails ? contactDetails.trustStatus : 0
messageDetails.sender.profileImage.name: contactDetails ? contactDetails.displayIcon : ""
messageDetails.sender.profileImage.assetSettings.isImage: true
messageDetails.sender.profileImage.pubkey: contactId
messageDetails.sender.profileImage.colorId: Utils.colorIdForPubkey(notification ? contactId : "")
messageDetails.sender.profileImage.colorHash: Utils.getColorHashAsJson(notification ? contactId : "", contactDetails.ensVerified)
messageSubheaderComponent: !isOutgoingRequest ? subheaderComponent : null
Component {
id: subheaderComponent
StatusBaseText {
text: qsTr("Sent contact request:")
color: Theme.palette.baseColor1
font.italic: true
font.pixelSize: 15
}
}
ctaComponent: ContactRequestCta {
isOutgoingRequest: root.isOutgoingRequest
pending: root.pending
accepted: root.accepted
dismissed: root.dismissed
blocked: contactDetails && contactDetails.isBlocked
onAcceptClicked: root.store.contactsStore.acceptContactRequest(senderId)
onDeclineClicked: root.store.contactsStore.dismissContactRequest(senderId)
onProfileClicked: Global.openProfilePopup(senderId)
onAcceptClicked: root.store.contactsStore.acceptContactRequest(root.contactId)
onDeclineClicked: root.store.contactsStore.dismissContactRequest(root.contactId)
onProfileClicked: Global.openProfilePopup(root.contactId)
onBlockClicked: {
root.store.contactsStore.dismissContactRequest(senderId)
root.store.contactsStore.blockContact(senderId)
root.store.contactsStore.dismissContactRequest(root.contactId)
root.store.contactsStore.blockContact(root.contactId)
}
onDetailsClicked: {
Global.openPopup(reviewContactRequestPopupComponent,
{
messageDetails: root.messageDetails,
timestampString: root.timestampString,
timestampTooltipString: root.timestampTooltipString
})
Global.openPopup(reviewContactRequestPopupComponent, {
messageDetails: root.messageDetails,
timestampString: root.timestampString,
timestampTooltipString: root.timestampTooltipString
})
}
}
Component {
id: reviewContactRequestPopupComponent
ReviewContactRequestPopup {
id: reviewRequestPopup
onAccepted: root.store.contactsStore.acceptContactRequest(notification.message.senderId)
onDeclined: root.store.contactsStore.dismissContactRequest(notification.message.senderId)
onAccepted: root.store.contactsStore.acceptContactRequest(root.contactId)
onDeclined: root.store.contactsStore.dismissContactRequest(root.contactId)
}
}
}