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 { ActivityNotificationMessage {
id: root 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 pending: notification && notification.message.contactRequestState === Constants.contactRequestStatePending
readonly property bool accepted: notification && notification.message.contactRequestState === Constants.contactRequestStateAccepted readonly property bool accepted: notification && notification.message.contactRequestState === Constants.contactRequestStateAccepted
readonly property bool dismissed: notification && notification.message.contactRequestState === Constants.contactRequestStateDismissed readonly property bool dismissed: notification && notification.message.contactRequestState === Constants.contactRequestStateDismissed
maximumLineCount: 5 maximumLineCount: 5
messageDetails.messageText: { messageDetails.messageText: {
if (isOutgoingRequest && contactDetails) { if (isOutgoingRequest && contactDetails) {
const status = accepted ? qsTr("accepted") : dismissed ? qsTr("dismissed") : qsTr("recieved") const status = accepted ? qsTr("accepted") : dismissed ? qsTr("dismissed") : qsTr("recieved")
@ -37,17 +32,6 @@ ActivityNotificationMessage {
return "" 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 messageSubheaderComponent: !isOutgoingRequest ? subheaderComponent : null

View File

@ -15,26 +15,12 @@ import "../panels"
ActivityNotificationMessage { ActivityNotificationMessage {
id: root 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: { messageDetails.messageText: {
if (!notification) if (!notification)
return "" return ""
return root.isOutgoingRequest ? notification.repliedMessage.messageText : notification.message.messageText 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 { messageSubheaderComponent: StatusBaseText {
text: { text: {

View File

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