2022-09-16 13:06:52 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
2022-11-16 17:17:38 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as CoreUtils
|
2022-09-16 13:06:52 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
2023-01-13 13:32:36 +00:00
|
|
|
import shared.views.chat 1.0
|
2022-09-16 13:06:52 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
ActivityNotificationBase {
|
|
|
|
id: root
|
|
|
|
|
2023-06-08 12:52:03 +00:00
|
|
|
readonly property bool isOutgoingMessage: notification && notification.message && notification.message.amISender
|
2023-03-14 10:09:05 +00:00
|
|
|
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) : ""
|
2022-09-20 16:11:29 +00:00
|
|
|
|
2022-12-30 09:08:25 +00:00
|
|
|
property var contactDetails: null
|
2022-11-16 17:17:38 +00:00
|
|
|
property int maximumLineCount: 2
|
2022-09-16 13:06:52 +00:00
|
|
|
|
2022-11-22 22:01:30 +00:00
|
|
|
signal messageClicked()
|
|
|
|
|
2022-11-16 17:17:38 +00:00
|
|
|
property StatusMessageDetails messageDetails: StatusMessageDetails {
|
2023-06-08 12:52:03 +00:00
|
|
|
messageText: notification && notification.message ? notification.message.messageText : ""
|
2022-12-29 15:46:28 +00:00
|
|
|
amISender: false
|
|
|
|
sender.id: contactId
|
2023-03-14 10:09:05 +00:00
|
|
|
sender.displayName: contactName
|
2023-04-19 16:48:57 +00:00
|
|
|
sender.secondaryName: contactDetails && contactDetails.localNickname ?
|
|
|
|
ProfileUtils.displayName("", contactDetails.name, contactDetails.displayName, contactDetails.alias) : ""
|
2022-12-29 15:46:28 +00:00
|
|
|
sender.trustIndicator: contactDetails ? contactDetails.trustStatus : Constants.trustStatus.unknown
|
2023-04-19 16:31:26 +00:00
|
|
|
sender.isEnsVerified: !!contactDetails && contactDetails.ensVerified
|
|
|
|
sender.isContact: !!contactDetails && contactDetails.isContact
|
2022-11-16 17:17:38 +00:00
|
|
|
sender.profileImage {
|
|
|
|
width: 40
|
|
|
|
height: 40
|
2022-12-29 15:46:28 +00:00
|
|
|
name: contactDetails ? contactDetails.displayIcon : ""
|
|
|
|
pubkey: contactId
|
|
|
|
colorId: Utils.colorIdForPubkey(contactId)
|
2023-04-19 16:31:26 +00:00
|
|
|
colorHash: Utils.getColorHashAsJson(contactId, sender.isEnsVerified)
|
2022-11-16 17:17:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property Component messageSubheaderComponent: null
|
|
|
|
property Component messageBadgeComponent: null
|
|
|
|
|
|
|
|
function openProfilePopup() {
|
|
|
|
closeActivityCenter()
|
2022-12-29 15:46:28 +00:00
|
|
|
Global.openProfilePopup(contactId)
|
2022-11-16 17:17:38 +00:00
|
|
|
}
|
2022-11-30 11:15:29 +00:00
|
|
|
|
2022-12-30 09:08:25 +00:00
|
|
|
function updateContactDetails() {
|
|
|
|
contactDetails = notification ? Utils.getContactDetailsAsJson(contactId, false) : null
|
|
|
|
}
|
|
|
|
|
|
|
|
onContactIdChanged: root.updateContactDetails()
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root.store.contactsStore.myContactsModel
|
|
|
|
|
|
|
|
function onItemChanged(pubKey) {
|
|
|
|
if (pubKey === root.contactId)
|
|
|
|
root.updateContactDetails()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-19 16:28:23 +00:00
|
|
|
Connections {
|
|
|
|
target: Global
|
|
|
|
|
|
|
|
function onContactRenamed(pubKey) {
|
|
|
|
if (pubKey === root.contactId)
|
|
|
|
root.updateContactDetails()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-22 22:01:30 +00:00
|
|
|
bodyComponent: MouseArea {
|
2023-02-15 12:24:18 +00:00
|
|
|
implicitWidth: parent.width
|
|
|
|
implicitHeight: messageView.implicitHeight
|
2022-11-22 22:01:30 +00:00
|
|
|
hoverEnabled: root.messageBadgeComponent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2022-12-01 10:24:25 +00:00
|
|
|
onClicked: {
|
|
|
|
root.activityCenterStore.switchTo(notification)
|
|
|
|
root.closeActivityCenter()
|
|
|
|
}
|
2022-11-30 11:15:29 +00:00
|
|
|
|
2023-01-13 13:32:36 +00:00
|
|
|
SimplifiedMessageView {
|
|
|
|
id: messageView
|
2022-11-22 22:01:30 +00:00
|
|
|
width: parent.width
|
2023-01-13 13:32:36 +00:00
|
|
|
maximumLineCount: root.maximumLineCount
|
|
|
|
messageDetails: root.messageDetails
|
2023-01-10 11:36:03 +00:00
|
|
|
timestamp: notification ? notification.timestamp : 0
|
2023-01-13 13:32:36 +00:00
|
|
|
messageSubheaderComponent: root.messageSubheaderComponent
|
|
|
|
messageBadgeComponent: root.messageBadgeComponent
|
|
|
|
onOpenProfilePopup: root.openProfilePopup()
|
2022-09-16 13:06:52 +00:00
|
|
|
}
|
2022-09-20 16:11:29 +00:00
|
|
|
}
|
2022-11-22 22:01:30 +00:00
|
|
|
}
|