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
|
|
|
|
|
2022-12-29 19:46:28 +04:00
|
|
|
readonly property bool isOutgoingRequest: notification && notification.message.amISender
|
|
|
|
readonly property string contactId: notification ? isOutgoingRequest ? notification.chatId : notification.author : ""
|
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 {
|
2022-11-30 15:15:29 +04:00
|
|
|
messageText: notification ? notification.message.messageText : ""
|
2022-12-29 19:46:28 +04:00
|
|
|
amISender: false
|
|
|
|
sender.id: contactId
|
|
|
|
sender.displayName: contactDetails ? contactDetails.displayName : ""
|
|
|
|
sender.secondaryName: contactDetails ? contactDetails.localNickname : ""
|
|
|
|
sender.trustIndicator: contactDetails ? contactDetails.trustStatus : Constants.trustStatus.unknown
|
2022-11-16 21:17:38 +04:00
|
|
|
sender.profileImage {
|
|
|
|
width: 40
|
|
|
|
height: 40
|
2022-12-29 19:46:28 +04:00
|
|
|
name: contactDetails ? contactDetails.displayIcon : ""
|
|
|
|
assetSettings.isImage: contactDetails && contactDetails.displayIcon.startsWith("data")
|
|
|
|
pubkey: contactId
|
|
|
|
colorId: Utils.colorIdForPubkey(contactId)
|
2023-01-18 16:02:46 +04:00
|
|
|
colorHash: Utils.getColorHashAsJson(contactId, contactDetails && contactDetails.ensVerified)
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-23 01:01:30 +03:00
|
|
|
bodyComponent: MouseArea {
|
2023-01-13 17:32:36 +04:00
|
|
|
height: 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: {
|
|
|
|
root.activityCenterStore.switchTo(notification)
|
|
|
|
root.closeActivityCenter()
|
|
|
|
}
|
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
|
|
|
}
|