2020-11-30 17:03:52 +00:00
|
|
|
import QtQuick 2.13
|
2021-10-26 14:21:08 +00:00
|
|
|
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
2021-10-28 20:23:30 +00:00
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.status 1.0
|
|
|
|
import shared.controls 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.panels.chat 1.0
|
|
|
|
import shared.views.chat 1.0
|
|
|
|
import shared.controls.chat 1.0
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2021-10-21 00:41:54 +00:00
|
|
|
Column {
|
2021-07-16 15:02:47 +00:00
|
|
|
id: root
|
|
|
|
width: parent.width
|
|
|
|
anchors.right: !isCurrentUser ? undefined : parent.right
|
|
|
|
z: (typeof chatLogView === "undefined") ? 1 : (chatLogView.count - index)
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
property var messageStore
|
2022-01-04 12:06:05 +00:00
|
|
|
property var contactsStore
|
2021-12-14 14:19:55 +00:00
|
|
|
property var messageContextMenu
|
2021-12-09 12:53:40 +00:00
|
|
|
|
|
|
|
property string messageId: ""
|
|
|
|
property string responseToMessageWithId: ""
|
|
|
|
property string senderId: ""
|
|
|
|
property string senderDisplayName: ""
|
|
|
|
property string senderLocalName: ""
|
|
|
|
property string senderIcon: ""
|
|
|
|
property bool isSenderIconIdenticon: true
|
|
|
|
property bool amISender: false
|
|
|
|
property string message: ""
|
|
|
|
property string messageImage: ""
|
|
|
|
property string messageTimestamp: ""
|
|
|
|
property string messageOutgoingStatus: ""
|
|
|
|
property int messageContentType: 1
|
|
|
|
property bool pinnedMessage: false
|
2022-01-05 15:50:03 +00:00
|
|
|
property string messagePinnedBy: ""
|
2021-12-29 10:32:43 +00:00
|
|
|
property var reactionsModel: []
|
2021-12-09 12:53:40 +00:00
|
|
|
|
|
|
|
property int prevMessageIndex: -1
|
|
|
|
property var prevMessageAsJsonObj
|
|
|
|
property int nextMessageIndex: -1
|
|
|
|
property var nextMessageAsJsonObj
|
|
|
|
|
|
|
|
property string hoveredMessage
|
|
|
|
property string activeMessage
|
|
|
|
property bool isHovered: typeof hoveredMessage !== "undefined" && hoveredMessage === messageId
|
|
|
|
property bool isMessageActive: typeof activeMessage !== "undefined" && activeMessage === messageId
|
|
|
|
|
|
|
|
function setHovered(messageId, hovered) {
|
|
|
|
if (hovered) {
|
|
|
|
hoveredMessage = messageId;
|
|
|
|
} else if (hoveredMessage === messageId) {
|
|
|
|
hoveredMessage = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setMessageActive(messageId, active) {
|
|
|
|
if (active) {
|
|
|
|
activeMessage = messageId;
|
|
|
|
} else if (activeMessage === messageId) {
|
|
|
|
activeMessage = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Legacy
|
|
|
|
property string responseTo: responseToMessageWithId
|
|
|
|
property bool isCurrentUser: amISender
|
|
|
|
property int contentType: messageContentType
|
|
|
|
property string timestamp: messageTimestamp
|
|
|
|
property string displayUserName: senderDisplayName
|
|
|
|
property string outgoingStatus: messageOutgoingStatus
|
|
|
|
property string authorCurrentMsg: senderId
|
|
|
|
property string authorPrevMsg: {
|
|
|
|
if(!prevMessageAsJsonObj)
|
|
|
|
return ""
|
|
|
|
|
|
|
|
return prevMessageAsJsonObj.senderId
|
|
|
|
}
|
|
|
|
property string prevMsgTimestamp: {
|
|
|
|
if(!prevMessageAsJsonObj)
|
|
|
|
return ""
|
|
|
|
|
|
|
|
return prevMessageAsJsonObj.timestamp
|
|
|
|
}
|
|
|
|
property string nextMsgTimestamp: {
|
|
|
|
if(!nextMessageAsJsonObj)
|
|
|
|
return ""
|
|
|
|
|
|
|
|
return nextMessageAsJsonObj.timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
property bool shouldRepeatHeader: ((parseInt(timestamp, 10) - parseInt(prevMsgTimestamp, 10)) / 60 / 1000) > Constants.repeatHeaderInterval
|
2021-10-21 22:39:53 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
//////////////////////////////////////
|
2021-12-10 16:11:18 +00:00
|
|
|
//TODO CHECCK - REMOVE
|
2020-07-10 15:24:52 +00:00
|
|
|
property string plainText: "That's right. We're friends... Of justice, that is."
|
2020-05-28 21:34:04 +00:00
|
|
|
property string sticker: "Qme8vJtyrEHxABcSVGPF95PtozDgUyfr1xGjePmFdZgk9v"
|
2020-08-12 15:01:03 +00:00
|
|
|
property string emojiReactions: ""
|
2020-07-14 15:35:21 +00:00
|
|
|
property bool timeout: false
|
2021-02-01 18:40:55 +00:00
|
|
|
property bool hasMention: false
|
2020-11-25 10:43:36 +00:00
|
|
|
property string linkUrls: ""
|
2020-11-30 17:03:52 +00:00
|
|
|
property bool placeholderMessage: false
|
2021-06-11 17:41:59 +00:00
|
|
|
property bool activityCenterMessage: false
|
2021-06-14 15:40:05 +00:00
|
|
|
property bool read: true
|
2021-05-25 19:34:46 +00:00
|
|
|
property bool forceHoverHandler: false // Used to force the HoverHandler to be active (useful for messages in popups)
|
2021-03-08 19:24:39 +00:00
|
|
|
property int stickerPackId: -1
|
2021-05-10 19:12:26 +00:00
|
|
|
property int gapFrom: 0
|
|
|
|
property int gapTo: 0
|
2021-06-29 14:49:32 +00:00
|
|
|
property bool isEdit: false
|
|
|
|
property string replaces: ""
|
|
|
|
property bool isEdited: false
|
2021-07-09 14:18:45 +00:00
|
|
|
property bool showEdit: true
|
2022-01-05 15:50:03 +00:00
|
|
|
property bool stickersLoaded: false
|
2021-12-10 16:11:18 +00:00
|
|
|
//////////////////////////////////////
|
2021-12-09 12:53:40 +00:00
|
|
|
|
|
|
|
property bool isEmoji: contentType === Constants.messageContentType.emojiType
|
|
|
|
property bool isImage: contentType === Constants.messageContentType.imageType
|
|
|
|
property bool isAudio: contentType === Constants.messageContentType.audioType
|
|
|
|
property bool isStatusMessage: contentType === Constants.messageContentType.systemMessagePrivateGroupType
|
|
|
|
property bool isSticker: contentType === Constants.messageContentType.stickerType
|
|
|
|
property bool isText: contentType === Constants.messageContentType.messageType || contentType === Constants.messageContentType.editType
|
2021-02-01 18:40:55 +00:00
|
|
|
property bool isMessage: isEmoji || isImage || isSticker || isText || isAudio
|
2021-12-09 12:53:40 +00:00
|
|
|
|| contentType === Constants.messageContentType.communityInviteType || contentType === Constants.messageContentType.transactionType
|
2020-06-10 15:14:12 +00:00
|
|
|
|
2021-04-23 15:49:05 +00:00
|
|
|
property bool isExpired: (outgoingStatus === "sending" && (Math.floor(timestamp) + 180000) < Date.now())
|
2021-12-09 12:53:40 +00:00
|
|
|
property bool isStatusUpdate: false
|
2021-07-15 14:59:30 +00:00
|
|
|
property int statusAgeEpoch: 0
|
2020-07-16 17:27:09 +00:00
|
|
|
|
2021-12-08 21:20:43 +00:00
|
|
|
signal imageClick(var image)
|
2020-07-10 15:37:23 +00:00
|
|
|
property var scrollToBottom: function () {}
|
2020-11-30 17:03:52 +00:00
|
|
|
|
2021-12-14 14:19:55 +00:00
|
|
|
property var clickMessage: function(isProfileClick,
|
|
|
|
isSticker = false,
|
|
|
|
isImage = false,
|
|
|
|
image = null,
|
|
|
|
emojiOnly = false,
|
|
|
|
hideEmojiPicker = false,
|
|
|
|
isReply = false,
|
|
|
|
isRightClickOnImage = false,
|
|
|
|
imageSource = "") {
|
|
|
|
|
|
|
|
if (placeholderMessage || activityCenterMessage) {
|
|
|
|
return
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2021-12-14 14:19:55 +00:00
|
|
|
messageContextMenu.myPublicKey = userProfile.pubKey
|
2022-01-05 15:50:03 +00:00
|
|
|
messageContextMenu.amIChatAdmin = messageStore.amIChatAdmin()
|
2021-12-14 14:19:55 +00:00
|
|
|
messageContextMenu.chatType = messageStore.getChatType()
|
|
|
|
|
|
|
|
messageContextMenu.messageId = root.messageId
|
|
|
|
messageContextMenu.messageSenderId = root.senderId
|
|
|
|
messageContextMenu.messageContentType = root.messageContentType
|
|
|
|
messageContextMenu.pinnedMessage = root.pinnedMessage
|
2021-12-17 12:53:10 +00:00
|
|
|
messageContextMenu.canPin = messageStore.getNumberOfPinnedMessages() < Constants.maxNumberOfPins
|
2021-12-14 14:19:55 +00:00
|
|
|
|
|
|
|
messageContextMenu.selectedUserPublicKey = root.senderId
|
|
|
|
messageContextMenu.selectedUserDisplayName = root.senderDisplayName
|
|
|
|
messageContextMenu.selectedUserIcon = root.senderIcon
|
|
|
|
messageContextMenu.isSelectedUserIconIdenticon = root.isSenderIconIdenticon
|
|
|
|
|
|
|
|
messageContextMenu.imageSource = imageSource
|
|
|
|
|
|
|
|
messageContextMenu.isProfile = !!isProfileClick
|
|
|
|
messageContextMenu.isRightClickOnImage = isRightClickOnImage
|
|
|
|
messageContextMenu.emojiOnly = emojiOnly
|
|
|
|
messageContextMenu.hideEmojiPicker = hideEmojiPicker
|
|
|
|
|
|
|
|
if(isReply){
|
|
|
|
let obj = messageStore.getMessageByIdAsJson(responseTo)
|
|
|
|
if(!obj)
|
|
|
|
return
|
|
|
|
|
|
|
|
messageContextMenu.messageSenderId = obj.id
|
|
|
|
messageContextMenu.selectedUserPublicKey = obj.id
|
|
|
|
messageContextMenu.selectedUserDisplayName = obj.senderDisplayName
|
|
|
|
messageContextMenu.selectedUserIcon = obj.senderIcon
|
|
|
|
messageContextMenu.isSelectedUserIconIdenticon = obj.isSenderIconIdenticon
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
|
|
|
|
|
2021-12-14 14:19:55 +00:00
|
|
|
messageContextMenu.x = messageContextMenu.setXPosition()
|
|
|
|
messageContextMenu.y = messageContextMenu.setYPosition()
|
|
|
|
|
|
|
|
messageContextMenu.popup()
|
2020-06-17 12:53:51 +00:00
|
|
|
}
|
|
|
|
|
2022-01-12 12:55:26 +00:00
|
|
|
signal showReplyArea(string messageId, string author)
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// function showReactionAuthors(fromAccounts, emojiId) {
|
|
|
|
// return root.rootStore.showReactionAuthors(fromAccounts, emojiId)
|
|
|
|
// }
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// function startMessageFoundAnimation() {
|
|
|
|
// messageLoader.item.startMessageFoundAnimation();
|
|
|
|
// }
|
2021-10-01 15:58:36 +00:00
|
|
|
/////////////////////////////////////////////
|
|
|
|
|
2021-12-08 21:20:43 +00:00
|
|
|
|
|
|
|
signal openStickerPackPopup(string stickerPackId)
|
2021-12-09 12:53:40 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// Connections {
|
|
|
|
// enabled: (!placeholderMessage && !!root.rootStore)
|
|
|
|
// target: !!root.rootStore ? root.rootStore.allContacts : null
|
|
|
|
// onContactChanged: {
|
|
|
|
// if (pubkey === fromAuthor) {
|
|
|
|
// const img = appMain.getProfileImage(userPubKey, isCurrentUser, useLargeImage)
|
|
|
|
// if (img) {
|
|
|
|
// profileImageSource = img
|
|
|
|
// }
|
|
|
|
// } else if (replyMessageIndex > -1 && pubkey === repliedMessageAuthorPubkey) {
|
|
|
|
// const imgReply = appMain.getProfileImage(repliedMessageAuthorPubkey, repliedMessageAuthorIsCurrentUser, false)
|
|
|
|
// if (imgReply) {
|
|
|
|
// repliedMessageUserImage = imgReply
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2020-07-15 21:04:14 +00:00
|
|
|
Loader {
|
2021-09-22 08:25:55 +00:00
|
|
|
id: messageLoader
|
2021-11-25 15:36:03 +00:00
|
|
|
active: root.visible
|
2020-07-15 21:04:14 +00:00
|
|
|
width: parent.width
|
|
|
|
sourceComponent: {
|
|
|
|
switch(contentType) {
|
2021-12-09 12:53:40 +00:00
|
|
|
case Constants.messageContentType.chatIdentifier:
|
2020-07-15 21:04:14 +00:00
|
|
|
return channelIdentifierComponent
|
2021-12-09 12:53:40 +00:00
|
|
|
case Constants.messageContentType.fetchMoreMessagesButton:
|
2020-09-04 11:55:24 +00:00
|
|
|
return fetchMoreMessagesButtonComponent
|
2021-12-09 12:53:40 +00:00
|
|
|
case Constants.messageContentType.systemMessagePrivateGroupType:
|
2020-07-22 12:23:15 +00:00
|
|
|
return privateGroupHeaderComponent
|
2021-12-09 12:53:40 +00:00
|
|
|
case Constants.messageContentType.gapType:
|
2021-05-10 19:12:26 +00:00
|
|
|
return gapComponent
|
2020-07-15 21:04:14 +00:00
|
|
|
default:
|
2021-12-10 11:29:33 +00:00
|
|
|
return isStatusUpdate ? statusUpdateComponent : compactMessageComponent
|
2021-01-25 20:13:43 +00:00
|
|
|
|
2020-06-04 10:30:49 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 22:59:17 +00:00
|
|
|
}
|
|
|
|
|
2021-05-10 19:12:26 +00:00
|
|
|
Component {
|
|
|
|
id: gapComponent
|
2021-10-21 00:41:54 +00:00
|
|
|
GapComponent {
|
|
|
|
onClicked: {
|
2021-12-10 16:11:18 +00:00
|
|
|
// Not Refactored Yet - Should do it via messageStore
|
2021-12-09 12:53:40 +00:00
|
|
|
// root.chatsModel.messageView.fillGaps(messageStore.messageId);
|
|
|
|
// root.visible = false;
|
|
|
|
// root.height = 0;
|
2021-05-10 19:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-04 11:55:24 +00:00
|
|
|
Component {
|
|
|
|
id: fetchMoreMessagesButtonComponent
|
2021-10-21 00:41:54 +00:00
|
|
|
FetchMoreMessagesButton {
|
2021-12-10 16:11:18 +00:00
|
|
|
nextMessageIndex: root.nextMessageIndex
|
|
|
|
nextMsgTimestamp: root.nextMsgTimestamp
|
2021-12-09 12:53:40 +00:00
|
|
|
onClicked: {
|
2021-12-10 16:11:18 +00:00
|
|
|
// Not Refactored Yet - Should do it via messageStore
|
2021-12-09 12:53:40 +00:00
|
|
|
// root.chatsModel.messageView.hideLoadingIndicator();
|
|
|
|
}
|
2021-10-21 00:41:54 +00:00
|
|
|
onTimerTriggered: {
|
2021-12-10 16:11:18 +00:00
|
|
|
// Not Refactored Yet - Should do it via messageStore
|
2021-12-09 12:53:40 +00:00
|
|
|
// root.chatsModel.requestMoreMessages(Constants.fetchRangeLast24Hours);
|
2020-09-04 11:55:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-15 21:04:14 +00:00
|
|
|
Component {
|
|
|
|
id: channelIdentifierComponent
|
2021-12-10 16:11:18 +00:00
|
|
|
ChannelIdentifierView {
|
|
|
|
chatName: root.senderDisplayName
|
2021-12-14 14:19:55 +00:00
|
|
|
chatType: messageStore.getChatType()
|
|
|
|
chatColor: messageStore.getChatColor()
|
2021-12-10 16:11:18 +00:00
|
|
|
chatIcon: root.senderIcon
|
|
|
|
chatIconIsIdenticon: root.isSenderIconIdenticon
|
2020-06-10 18:23:18 +00:00
|
|
|
}
|
2020-05-27 22:59:17 +00:00
|
|
|
}
|
|
|
|
|
2020-07-15 21:04:14 +00:00
|
|
|
// Private group Messages
|
|
|
|
Component {
|
|
|
|
id: privateGroupHeaderComponent
|
|
|
|
StyledText {
|
2020-06-25 20:17:42 +00:00
|
|
|
wrapMode: Text.Wrap
|
2020-11-30 17:03:52 +00:00
|
|
|
text: {
|
2020-09-21 15:47:15 +00:00
|
|
|
return `<html>`+
|
|
|
|
`<head>`+
|
|
|
|
`<style type="text/css">`+
|
|
|
|
`a {`+
|
|
|
|
`color: ${Style.current.textColor};`+
|
|
|
|
`text-decoration: none;`+
|
|
|
|
`}`+
|
|
|
|
`</style>`+
|
|
|
|
`</head>`+
|
|
|
|
`<body>`+
|
|
|
|
`${message}`+
|
|
|
|
`</body>`+
|
|
|
|
`</html>`;
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
visible: isStatusMessage
|
2020-09-21 15:47:15 +00:00
|
|
|
font.pixelSize: 14
|
|
|
|
color: Style.current.secondaryText
|
2020-07-15 21:04:14 +00:00
|
|
|
width: parent.width - 120
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
textFormat: Text.RichText
|
2020-12-07 23:38:53 +00:00
|
|
|
topPadding: root.prevMessageIndex === 1 ? Style.current.bigPadding : 0
|
2020-07-09 17:47:36 +00:00
|
|
|
}
|
2020-07-09 15:50:38 +00:00
|
|
|
}
|
2020-05-28 19:32:14 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
Component {
|
|
|
|
id: statusUpdateComponent
|
|
|
|
StatusUpdateView {
|
|
|
|
statusAgeEpoch: root.statusAgeEpoch
|
2020-12-16 20:50:54 +00:00
|
|
|
container: root
|
2021-12-10 16:11:18 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// store: root.rootStore
|
2021-12-09 12:53:40 +00:00
|
|
|
messageContextMenu: root.messageContextMenu
|
|
|
|
onAddEmoji: {
|
|
|
|
root.clickMessage(isProfileClick, isSticker, isImage , image, emojiOnly, hideEmojiPicker);
|
|
|
|
}
|
|
|
|
onChatImageClicked: {
|
2021-12-10 16:11:18 +00:00
|
|
|
// Not Refactored Yet - Should do it via messageStore
|
2021-12-08 21:20:43 +00:00
|
|
|
// root.imageClick(image);
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
onUserNameClicked: {
|
2021-12-10 16:11:18 +00:00
|
|
|
// Not Refactored Yet - Should do it via messageStore
|
|
|
|
// root.parent.clickMessage(isProfileClick);
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
onEmojiBtnClicked: {
|
2021-12-10 16:11:18 +00:00
|
|
|
// Not Refactored Yet - Should do it via messageStore
|
|
|
|
// root.parent.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly);
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
onClickMessage: {
|
2021-12-10 16:11:18 +00:00
|
|
|
// Not Refactored Yet - Should do it via messageStore
|
|
|
|
// root.parent.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly, hideEmojiPicker, isReply);
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
onSetMessageActive: {
|
2021-12-20 14:21:35 +00:00
|
|
|
root.setMessageActive(messageId, active);
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
2020-05-28 19:32:14 +00:00
|
|
|
}
|
2020-07-09 15:50:38 +00:00
|
|
|
}
|
2020-07-10 15:37:23 +00:00
|
|
|
|
2020-07-15 21:04:14 +00:00
|
|
|
Component {
|
|
|
|
id: compactMessageComponent
|
2021-10-01 15:58:36 +00:00
|
|
|
CompactMessageView {
|
2022-01-04 12:06:05 +00:00
|
|
|
contactsStore: root.contactsStore
|
2021-07-16 15:02:47 +00:00
|
|
|
messageContextMenu: root.messageContextMenu
|
2022-01-05 15:50:03 +00:00
|
|
|
|
|
|
|
stickersLoaded: root.stickersLoaded
|
|
|
|
isMessageActive: root.isMessageActive
|
|
|
|
isCurrentUser: root.amISender
|
|
|
|
isHovered: root.isHovered
|
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
onAddEmoji: {
|
2021-12-14 14:19:55 +00:00
|
|
|
root.clickMessage(isProfileClick, isSticker, isImage , image, emojiOnly, hideEmojiPicker)
|
|
|
|
}
|
|
|
|
|
|
|
|
onClickMessage: {
|
|
|
|
root.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly, hideEmojiPicker, isReply, isRightClickOnImage, imageSource)
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2021-12-08 21:20:43 +00:00
|
|
|
onOpenStickerPackPopup: {
|
|
|
|
root.openStickerPackPopup(stickerPackId);
|
|
|
|
}
|
2022-01-12 12:55:26 +00:00
|
|
|
|
|
|
|
onReplyClicked: {
|
|
|
|
root.showReplyArea(messageId, author)
|
|
|
|
}
|
2020-07-10 15:37:23 +00:00
|
|
|
}
|
2020-05-27 22:59:17 +00:00
|
|
|
}
|
|
|
|
}
|