fix(ActivityCenter): Fix contact request notifications

Close #9788
This commit is contained in:
MishkaRogachev 2023-03-14 15:39:05 +05:30 committed by Mikhail Rogachev
parent 579ca265b4
commit 0ae1881564
6 changed files with 25 additions and 34 deletions

View File

@ -424,6 +424,8 @@ QtObject:
contact.removed = false contact.removed = false
self.saveContact(contact) self.saveContact(contact)
self.events.emit(SIGNAL_CONTACT_ADDED, ContactArgs(contactId: contact.id)) self.events.emit(SIGNAL_CONTACT_ADDED, ContactArgs(contactId: contact.id))
self.activityCenterService.parseActivityCenterResponse(response)
except Exception as e: except Exception as e:
error "an error occurred while sending contact request", msg=e.msg error "an error occurred while sending contact request", msg=e.msg

View File

@ -43,6 +43,8 @@ Item {
color: { color: {
if (root.accepted) { if (root.accepted) {
return Theme.palette.successColor1 return Theme.palette.successColor1
} else if (root.pending) {
return Theme.palette.baseColor1
} else if (root.dismissed) { } else if (root.dismissed) {
return Theme.palette.dangerColor1 return Theme.palette.dangerColor1
} }

View File

@ -20,7 +20,7 @@ ActivityNotificationMessage {
readonly property bool dismissed: notification && notification.message.contactRequestState === Constants.contactRequestStateDismissed readonly property bool dismissed: notification && notification.message.contactRequestState === Constants.contactRequestStateDismissed
Connections { Connections {
target: root.isOutgoingRequest ? root.store.contactsStore.sentContactRequestsModel : target: root.isOutgoingMessage ? root.store.contactsStore.sentContactRequestsModel :
root.store.contactsStore.receivedContactRequestsModel root.store.contactsStore.receivedContactRequestsModel
function onItemChanged(pubKey) { function onItemChanged(pubKey) {
@ -30,34 +30,20 @@ ActivityNotificationMessage {
} }
maximumLineCount: 5 maximumLineCount: 5
messageDetails.messageText: { messageDetails.messageText: !root.isOutgoingMessage && notification ? notification.message.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)
}
if (!isOutgoingRequest && notification) { messageSubheaderComponent: StatusBaseText {
return notification.message.messageText text: root.isOutgoingMessage ? qsTr("Сontact request sent to %1").arg(contactName) :
} qsTr("Сontact request:")
font.italic: true
return "" font.pixelSize: 15
} maximumLineCount: 2
wrapMode: Text.WordWrap
messageSubheaderComponent: !isOutgoingRequest ? subheaderComponent : null color: Theme.palette.baseColor1
Component {
id: subheaderComponent
StatusBaseText {
text: qsTr("Sent contact request:")
color: Theme.palette.baseColor1
font.italic: true
font.pixelSize: 15
}
} }
ctaComponent: ContactRequestCta { ctaComponent: ContactRequestCta {
isOutgoingRequest: root.isOutgoingRequest isOutgoingRequest: root.isOutgoingMessage
pending: root.pending pending: root.pending
accepted: root.accepted accepted: root.accepted
dismissed: root.dismissed dismissed: root.dismissed

View File

@ -16,7 +16,7 @@ ActivityNotificationMessage {
id: root id: root
Connections { Connections {
target: root.isOutgoingRequest ? root.store.contactsStore.sentContactRequestsModel : target: root.isOutgoingMessage ? root.store.contactsStore.sentContactRequestsModel :
root.store.contactsStore.receivedContactRequestsModel root.store.contactsStore.receivedContactRequestsModel
function onItemChanged(pubKey) { function onItemChanged(pubKey) {
@ -29,7 +29,7 @@ ActivityNotificationMessage {
if (!notification) if (!notification)
return "" return ""
return root.isOutgoingRequest ? notification.repliedMessage.messageText : notification.message.messageText return root.isOutgoingMessage ? notification.repliedMessage.messageText : notification.message.messageText
} }
messageSubheaderComponent: StatusBaseText { messageSubheaderComponent: StatusBaseText {
@ -37,7 +37,7 @@ ActivityNotificationMessage {
if (!notification) if (!notification)
return "" return ""
if (root.isOutgoingRequest) { if (root.isOutgoingMessage) {
return qsTr("To verify their identity you asked: %1").arg(CoreUtils.Utils.stripHtmlTags(notification.message.messageText)) return qsTr("To verify their identity you asked: %1").arg(CoreUtils.Utils.stripHtmlTags(notification.message.messageText))
} }
@ -50,7 +50,7 @@ ActivityNotificationMessage {
font.pixelSize: 15 font.pixelSize: 15
} }
ctaComponent: isOutgoingRequest ? outgoingContactVerificationCta : incomingContactVerificationCta ctaComponent: isOutgoingMessage ? outgoingContactVerificationCta : incomingContactVerificationCta
Component { Component {
id: outgoingContactVerificationCta id: outgoingContactVerificationCta

View File

@ -12,8 +12,10 @@ import utils 1.0
ActivityNotificationBase { ActivityNotificationBase {
id: root id: root
readonly property bool isOutgoingRequest: notification && notification.message.amISender readonly property bool isOutgoingMessage: notification && notification.message.amISender
readonly property string contactId: notification ? isOutgoingRequest ? notification.chatId : notification.author : "" readonly property string contactId: notification ? isOutgoingMessage ? notification.chatId : notification.author : ""
readonly property string contactName: contactDetails ? ProfileUtils.displayName(contactDetails.localNickname, contactDetails.name,
contactDetails.displayName, contactDetails.alias) : ""
property var contactDetails: null property var contactDetails: null
property int maximumLineCount: 2 property int maximumLineCount: 2
@ -24,8 +26,7 @@ ActivityNotificationBase {
messageText: notification ? notification.message.messageText : "" messageText: notification ? notification.message.messageText : ""
amISender: false amISender: false
sender.id: contactId sender.id: contactId
sender.displayName: contactDetails ? ProfileUtils.displayName(contactDetails.localNickname, contactDetails.name, sender.displayName: contactName
contactDetails.displayName, contactDetails.alias) : ""
sender.secondaryName: contactDetails && contactDetails.localNickname ? sender.secondaryName: contactDetails && contactDetails.localNickname ?
ProfileUtils.displayName("", contactDetails.name, contactDetails.displayName, contactDetails.alias) : "" ProfileUtils.displayName("", contactDetails.name, contactDetails.displayName, contactDetails.alias) : ""
sender.trustIndicator: contactDetails ? contactDetails.trustStatus : Constants.trustStatus.unknown sender.trustIndicator: contactDetails ? contactDetails.trustStatus : Constants.trustStatus.unknown

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit dd7c59423f125f7e40b7423e56ae03fe8cfba6a8 Subproject commit 96532f97c460f849ed8b1ed5d2507593e3ca5c1c