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