fix(ActivityCenter): Unify ContactRequest and ContactVerification AC notifications

This commit is contained in:
MishkaRogachev 2022-12-29 19:46:28 +04:00 committed by Mikhail Rogachev
parent f70ccfc17d
commit 130a5f48b4
3 changed files with 16 additions and 46 deletions

View File

@ -15,16 +15,11 @@ 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
messageDetails.messageText: {
if (isOutgoingRequest && contactDetails) {
const status = accepted ? qsTr("accepted") : dismissed ? qsTr("dismissed") : qsTr("recieved")
@ -37,17 +32,6 @@ ActivityNotificationMessage {
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

View File

@ -15,26 +15,12 @@ import "../panels"
ActivityNotificationMessage {
id: root
readonly property bool isOutgoingRequest: notification && notification.message.senderId === root.store.contactsStore.myPublicKey
readonly property string contactId: notification ? isOutgoingRequest ? notification.chatId : notification.author : ""
readonly property var contactDetails: notification ? Utils.getContactDetailsAsJson(contactId, false) : null
messageDetails.messageText: {
if (!notification)
return ""
return root.isOutgoingRequest ? notification.repliedMessage.messageText : notification.message.messageText
}
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: StatusBaseText {
text: {

View File

@ -13,11 +13,12 @@ ActivityNotificationBase {
id: root
readonly property string timestampString: notification ?
new Date(notification.timestamp).toLocaleTimeString(Qt.locale(), Locale.ShortFormat) :
""
new Date(notification.timestamp).toLocaleTimeString(Qt.locale(), Locale.ShortFormat) : ""
readonly property string timestampTooltipString: notification ?
new Date(notification.timestamp).toLocaleString() :
""
new Date(notification.timestamp).toLocaleString() : ""
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
property int maximumLineCount: 2
@ -25,19 +26,19 @@ ActivityNotificationBase {
property StatusMessageDetails messageDetails: StatusMessageDetails {
messageText: notification ? notification.message.messageText : ""
amISender: notification ? notification.message.amISender : false
sender.id: notification ? notification.message.senderId : ""
sender.displayName: notification ? notification.message.senderDisplayName : ""
sender.secondaryName: notification ? notification.message.senderOptionalName : ""
sender.trustIndicator: notification ? notification.message.senderTrustStatus : Constants.trustStatus.unknown
amISender: false
sender.id: contactId
sender.displayName: contactDetails ? contactDetails.displayName : ""
sender.secondaryName: contactDetails ? contactDetails.localNickname : ""
sender.trustIndicator: contactDetails ? contactDetails.trustStatus : Constants.trustStatus.unknown
sender.profileImage {
width: 40
height: 40
name: notification ? notification.message.senderIcon || "" : ""
assetSettings.isImage: notification ? notification.message.senderIcon.startsWith("data") : false
pubkey: notification ? notification.message.senderId : ""
colorId: Utils.colorIdForPubkey(notification ? notification.message.senderId : "")
colorHash: Utils.getColorHashAsJson(notification ? notification.message.senderId : "")
name: contactDetails ? contactDetails.displayIcon : ""
assetSettings.isImage: contactDetails && contactDetails.displayIcon.startsWith("data")
pubkey: contactId
colorId: Utils.colorIdForPubkey(contactId)
colorHash: Utils.getColorHashAsJson(contactId, contactDetails.ensVerified)
}
}
@ -46,7 +47,7 @@ ActivityNotificationBase {
function openProfilePopup() {
closeActivityCenter()
Global.openProfilePopup(notification.message.senderId)
Global.openProfilePopup(contactId)
}
bodyComponent: MouseArea {
@ -116,7 +117,6 @@ ActivityNotificationBase {
elide: Text.ElideRight
font.pixelSize: 15
Layout.alignment: Qt.AlignVCenter
Layout.fillWidth: true
Layout.maximumWidth: 400 // From designs, fixed value to align all possible CTAs
}