2021-10-01 15:58:36 +00:00
|
|
|
|
import QtQuick 2.13
|
2021-01-25 20:50:42 +00:00
|
|
|
|
import QtGraphicalEffects 1.13
|
2021-10-21 15:07:13 +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-21 15:07:13 +00:00
|
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1 as StatusQControls
|
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
|
import "../panels"
|
|
|
|
|
import "../controls"
|
|
|
|
|
|
2020-07-15 21:04:14 +00:00
|
|
|
|
Item {
|
2021-07-16 15:02:47 +00:00
|
|
|
|
id: root
|
2021-10-01 15:58:36 +00:00
|
|
|
|
property var store
|
|
|
|
|
property var messageStore
|
2021-02-01 18:40:55 +00:00
|
|
|
|
property int chatHorizontalPadding: Style.current.halfPadding
|
2020-07-15 21:04:14 +00:00
|
|
|
|
property int chatVerticalPadding: 7
|
2021-10-01 15:58:36 +00:00
|
|
|
|
property string linkUrls: root.messageStore.linkUrls
|
2020-12-07 23:38:53 +00:00
|
|
|
|
property int contentType: 2
|
2020-12-16 20:50:54 +00:00
|
|
|
|
property var container
|
feat: whitelist gifs (no url extension needed)
Fixes #1377.
Fixes #1479.
Two sites have been added to the whitelist: giphy.com and tenor.com.
`imageUrls` in its entirety has been removed and instead all links are being handle through the message `linkUrls`. This prevents double-handling of urls that may or may not be images.
The logic to automatically show links previews works like this:
1. If the setting "display chat images" is enabled, all links that *contain* ".png", ".jpg", ".jpeg", ".svg", ".gif" will be automatically shown. If the URL doesn't contain the extension, we are not downloading it. This was meant to be somewhat of a security compromise as we do not want to download each and every link posted in a message just to find out its true content type.
2. If the above setting is *disabled*, then we follow the whitelist settings for tenor and giphy. This allows us to preview gifs that do not have a file extension in their url.
feat: bump status-go to the commit that supports the new whitelist (https://github.com/status-im/status-go/pull/2094), and also lets us get link preview data from urls in the whitelist. NOTE: this commit was branched off status-go `develop`, so once it is merged, and we update this PR to the new commit, we will effectively be getting status-go develop changes. We *could* base that status-go PR off of master if it makes things easier.
fix: height on settings update issue
feat: move date/time of message below links
fix: layout issues when changing setting `neverAskAboutUnfurlingAgain`
feat: Add MessageBorder component to aid in showing rounded corners with different radius
2020-12-11 00:53:44 +00:00
|
|
|
|
property bool isCurrentUser: false
|
2021-10-01 15:58:36 +00:00
|
|
|
|
property bool isHovered: typeof root.messageStore.hoveredMessage !== "undefined" && root.messageStore.hoveredMessage === messageId
|
|
|
|
|
property bool isMessageActive: typeof root.messageStore.activeMessage !== "undefined" && root.messageStore.activeMessage === messageId
|
2021-04-23 15:49:05 +00:00
|
|
|
|
property bool headerRepeatCondition: (authorCurrentMsg !== authorPrevMsg || shouldRepeatHeader || dateGroupLbl.visible || chatReply.active)
|
2021-10-01 15:58:36 +00:00
|
|
|
|
property bool showMoreButton: {
|
|
|
|
|
if (!!root.store) {
|
|
|
|
|
switch (root.store.chatsModelInst.channelView.activeChannel.chatType) {
|
|
|
|
|
case Constants.chatTypeOneToOne: return true
|
|
|
|
|
case Constants.chatTypePrivateGroupChat: return root.store.chatsModelInst.channelView.activeChannel.isAdmin(root.store.profileModelInst.profile.pubKey) ? true : isCurrentUser
|
|
|
|
|
case Constants.chatTypePublic: return isCurrentUser
|
|
|
|
|
case Constants.chatTypeCommunity: return root.store.chatsModelInst.communities.activeCommunity.admin ? true : isCurrentUser
|
|
|
|
|
case Constants.chatTypeStatusUpdate: return false
|
|
|
|
|
default: return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-09 14:18:45 +00:00
|
|
|
|
property bool showEdit: true
|
2021-07-16 15:02:47 +00:00
|
|
|
|
property var messageContextMenu
|
|
|
|
|
signal addEmoji(bool isProfileClick, bool isSticker, bool isImage , var image, bool emojiOnly, bool hideEmojiPicker)
|
2020-07-15 21:04:14 +00:00
|
|
|
|
|
2021-01-25 20:50:42 +00:00
|
|
|
|
width: parent.width
|
2021-01-26 20:29:33 +00:00
|
|
|
|
height: messageContainer.height + messageContainer.anchors.topMargin
|
|
|
|
|
+ (dateGroupLbl.visible ? dateGroupLbl.height + dateGroupLbl.anchors.topMargin : 0)
|
2020-07-15 21:04:14 +00:00
|
|
|
|
|
2021-08-02 13:38:03 +00:00
|
|
|
|
Timer {
|
|
|
|
|
id: ensureMessageFullyVisibleTimer
|
|
|
|
|
interval: 1
|
|
|
|
|
onTriggered: {
|
|
|
|
|
chatLogView.positionViewAtIndex(ListView.currentIndex, ListView.Contain)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 20:50:42 +00:00
|
|
|
|
MouseArea {
|
2021-06-10 19:20:43 +00:00
|
|
|
|
enabled: !placeholderMessage
|
2021-01-25 20:50:42 +00:00
|
|
|
|
anchors.fill: messageContainer
|
2021-06-10 19:20:43 +00:00
|
|
|
|
acceptedButtons: activityCenterMessage ? Qt.LeftButton : Qt.RightButton
|
|
|
|
|
onClicked: {
|
|
|
|
|
messageMouseArea.clicked(mouse)
|
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
|
ChatButtonsPanel {
|
2021-03-24 17:30:15 +00:00
|
|
|
|
contentType: root.contentType
|
2021-06-29 14:49:32 +00:00
|
|
|
|
parentIsHovered: !isEdit && root.isHovered
|
2021-10-01 15:58:36 +00:00
|
|
|
|
onHoverChanged: {
|
|
|
|
|
hovered && root.messageStore.setHovered(messageId, hovered)
|
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
|
anchors.right: parent.right
|
2021-01-25 20:50:42 +00:00
|
|
|
|
anchors.rightMargin: 20
|
2021-02-01 19:05:34 +00:00
|
|
|
|
anchors.top: messageContainer.top
|
2021-01-25 20:50:42 +00:00
|
|
|
|
// This is not exactly like the design because the hover becomes messed up with the buttons on top of another Message
|
|
|
|
|
anchors.topMargin: -Style.current.halfPadding
|
2021-07-16 15:02:47 +00:00
|
|
|
|
messageContextMenu: root.messageContextMenu
|
2021-08-06 15:44:57 +00:00
|
|
|
|
showMoreButton: root.showMoreButton
|
2021-10-01 15:58:36 +00:00
|
|
|
|
fromAuthor: fromAuthor
|
|
|
|
|
editBtnActive: isText && !isEdit && isCurrentUser && showEdit
|
|
|
|
|
onClickMessage: {
|
|
|
|
|
parent.parent.parent.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly);
|
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-20 17:34:20 +00:00
|
|
|
|
Loader {
|
2021-01-25 20:50:42 +00:00
|
|
|
|
active: typeof messageContextMenu !== "undefined"
|
2020-09-30 18:16:16 +00:00
|
|
|
|
sourceComponent: Component {
|
2021-01-25 20:50:42 +00:00
|
|
|
|
Connections {
|
|
|
|
|
enabled: root.isMessageActive
|
|
|
|
|
target: messageContextMenu
|
2021-10-01 15:58:36 +00:00
|
|
|
|
onClosed: root.messageStore.setMessageActive(messageId, false)
|
2020-09-30 18:16:16 +00:00
|
|
|
|
}
|
2020-07-20 17:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-26 20:29:33 +00:00
|
|
|
|
DateGroup {
|
|
|
|
|
id: dateGroupLbl
|
2021-06-11 17:41:59 +00:00
|
|
|
|
previousMessageIndex: prevMessageIndex
|
|
|
|
|
previousMessageTimestamp: prevMsgTimestamp
|
|
|
|
|
messageTimestamp: timestamp
|
2021-06-15 19:34:36 +00:00
|
|
|
|
isActivityCenterMessage: activityCenterMessage
|
2021-01-26 20:29:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-22 08:25:55 +00:00
|
|
|
|
function startMessageFoundAnimation() {
|
|
|
|
|
messageFoundAnimation.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SequentialAnimation {
|
|
|
|
|
id: messageFoundAnimation
|
|
|
|
|
PauseAnimation {
|
|
|
|
|
duration: 600
|
|
|
|
|
}
|
|
|
|
|
NumberAnimation {
|
|
|
|
|
target: highlightRect
|
|
|
|
|
property: "opacity"
|
|
|
|
|
to: 1.0
|
|
|
|
|
duration: 1500
|
|
|
|
|
}
|
|
|
|
|
PauseAnimation {
|
|
|
|
|
duration: 1000
|
|
|
|
|
}
|
|
|
|
|
NumberAnimation {
|
|
|
|
|
target: highlightRect
|
|
|
|
|
property: "opacity"
|
|
|
|
|
to: 0.0
|
|
|
|
|
duration: 1500
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: highlightRect
|
|
|
|
|
anchors.fill: messageContainer
|
|
|
|
|
opacity: 0
|
|
|
|
|
visible: (opacity > 0.001)
|
|
|
|
|
color: Style.current.backgroundHoverLight
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 20:50:42 +00:00
|
|
|
|
Rectangle {
|
|
|
|
|
property alias chatText: chatText
|
2020-07-15 21:04:14 +00:00
|
|
|
|
|
2021-01-25 20:50:42 +00:00
|
|
|
|
id: messageContainer
|
2021-01-26 20:29:33 +00:00
|
|
|
|
anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
|
2021-06-11 17:41:59 +00:00
|
|
|
|
anchors.topMargin: dateGroupLbl.visible ? (activityCenterMessage ? 4 : Style.current.padding) : 0
|
2021-02-22 19:47:32 +00:00
|
|
|
|
height: childrenRect.height
|
2021-04-30 14:45:13 +00:00
|
|
|
|
+ (chatName.visible || emojiReactionLoader.active ? Style.current.halfPadding : 0)
|
2021-04-28 17:58:40 +00:00
|
|
|
|
+ (chatName.visible && emojiReactionLoader.active ? Style.current.padding : 0)
|
2021-04-30 14:45:13 +00:00
|
|
|
|
+ (!chatName.visible && chatImageContent.active ? 6 : 0)
|
2021-02-01 18:40:55 +00:00
|
|
|
|
+ (emojiReactionLoader.active ? emojiReactionLoader.height: 0)
|
|
|
|
|
+ (retry.visible && !chatTime.visible ? Style.current.smallPadding : 0)
|
2021-05-25 19:34:46 +00:00
|
|
|
|
+ (pinnedRectangleLoader.active ? Style.current.smallPadding : 0)
|
2021-06-29 14:49:32 +00:00
|
|
|
|
+ (isEdit ? 25 : 0)
|
2021-01-25 20:50:42 +00:00
|
|
|
|
width: parent.width
|
2021-05-25 19:34:46 +00:00
|
|
|
|
color: {
|
2021-06-29 14:49:32 +00:00
|
|
|
|
if (isEdit) {
|
|
|
|
|
return Style.current.backgroundHoverLight
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 15:40:05 +00:00
|
|
|
|
if (activityCenterMessage) {
|
|
|
|
|
return read ? Style.current.transparent : Utils.setColorAlpha(Style.current.blue, 0.1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (placeholderMessage) {
|
2021-06-11 17:41:59 +00:00
|
|
|
|
return Style.current.transparent
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-25 19:34:46 +00:00
|
|
|
|
if (pinnedMessage) {
|
|
|
|
|
return root.isHovered || isMessageActive ? Style.current.pinnedMessageBackgroundHovered : Style.current.pinnedMessageBackground
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return root.isHovered || isMessageActive ? (hasMention ? Style.current.mentionMessageHoverColor : Style.current.backgroundHoverLight) :
|
2021-09-22 08:25:55 +00:00
|
|
|
|
(hasMention ? Style.current.mentionMessageColor : Style.current.transparent)
|
2021-05-25 19:34:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
id: pinnedRectangleLoader
|
2021-07-01 15:15:09 +00:00
|
|
|
|
active: !isEdit && pinnedMessage
|
2021-05-25 19:34:46 +00:00
|
|
|
|
anchors.left: chatName.left
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: active ? Style.current.halfPadding : 0
|
|
|
|
|
|
|
|
|
|
sourceComponent: Component {
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: pinnedRectangle
|
|
|
|
|
height: 24
|
|
|
|
|
width: childrenRect.width + Style.current.smallPadding
|
|
|
|
|
color: Style.current.pinnedRectangleBackground
|
|
|
|
|
radius: 12
|
|
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
|
id: pinImage
|
2021-09-28 15:04:06 +00:00
|
|
|
|
source: Style.svg("pin")
|
2021-05-25 19:34:46 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 3
|
2021-05-25 19:38:18 +00:00
|
|
|
|
width: 16
|
|
|
|
|
height: 16
|
2021-05-25 19:34:46 +00:00
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
|
|
ColorOverlay {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
source: parent
|
|
|
|
|
color: Style.current.pinnedMessageBorder
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Pinned by %1"
|
2021-10-01 15:58:36 +00:00
|
|
|
|
text: qsTrId("pinned-by--1").arg(root.store.chatsModelInst.alias(pinnedBy))
|
2021-05-25 19:34:46 +00:00
|
|
|
|
anchors.left: pinImage.right
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
font.pixelSize: 13
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-25 20:50:42 +00:00
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
|
|
|
|
Connections {
|
2021-10-21 22:39:53 +00:00
|
|
|
|
enabled: !!root.store
|
|
|
|
|
target: enabled ? root.store.chatsModelInst.messageView : null
|
2021-10-01 15:58:36 +00:00
|
|
|
|
onMessageEdited: {
|
|
|
|
|
if(chatReply.item)
|
|
|
|
|
chatReply.item.messageEdited(editedMessageId, editedMessageContent)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChatReplyPanel {
|
2021-04-23 15:49:05 +00:00
|
|
|
|
id: chatReply
|
2021-05-25 19:34:46 +00:00
|
|
|
|
anchors.top: pinnedRectangleLoader.active ? pinnedRectangleLoader.bottom : parent.top
|
|
|
|
|
anchors.topMargin: active ? 4 : 0
|
2021-04-23 15:49:05 +00:00
|
|
|
|
anchors.left: chatImage.left
|
2021-10-01 15:58:36 +00:00
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
|
|
2021-04-23 15:49:05 +00:00
|
|
|
|
longReply: active && textFieldImplicitWidth > width
|
|
|
|
|
container: root.container
|
|
|
|
|
chatHorizontalPadding: root.chatHorizontalPadding
|
2021-10-21 22:39:53 +00:00
|
|
|
|
stickerData: !!root.store ? root.store.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "sticker") : null
|
2021-10-01 15:58:36 +00:00
|
|
|
|
active: responseTo !== "" && replyMessageIndex > -1 && !activityCenterMessage
|
|
|
|
|
// To-Do move to store later?
|
|
|
|
|
// isCurrentUser: root.messageStore.isCurrentUser
|
|
|
|
|
// repliedMessageType: root.messageStore.repliedMessageType
|
|
|
|
|
// repliedMessageImage: root.messageStore.repliedMessageImage
|
|
|
|
|
// repliedMessageUserIdenticon: root.messageStore.repliedMessageUserIdenticon
|
|
|
|
|
// repliedMessageIsEdited: root.messageStore.repliedMessageIsEdited
|
|
|
|
|
// repliedMessageUserImage: root.messageStore.repliedMessageUserImage
|
|
|
|
|
// repliedMessageAuthor: root.messageStore.repliedMessageAuthor
|
|
|
|
|
// repliedMessageContent: root.messageStore.repliedMessageContent
|
|
|
|
|
// responseTo: root.messageStore.responseTo
|
|
|
|
|
// onScrollToBottom: {
|
|
|
|
|
// root.messageStore.scrollToBottom(isit, container);
|
|
|
|
|
// }
|
|
|
|
|
onClickMessage: {
|
|
|
|
|
parent.parent.parent.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly, hideEmojiPicker, isReply);
|
|
|
|
|
}
|
2021-04-23 15:49:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
2021-01-25 20:50:42 +00:00
|
|
|
|
UserImage {
|
|
|
|
|
id: chatImage
|
2021-04-06 14:59:59 +00:00
|
|
|
|
active: isMessage && headerRepeatCondition
|
2021-01-25 20:50:42 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
2021-05-25 19:34:46 +00:00
|
|
|
|
anchors.top: chatReply.active ? chatReply.bottom :
|
|
|
|
|
pinnedRectangleLoader.active ? pinnedRectangleLoader.bottom : parent.top
|
|
|
|
|
anchors.topMargin: chatReply.active || pinnedRectangleLoader.active ? 4 : Style.current.smallPadding
|
2021-10-01 15:58:36 +00:00
|
|
|
|
// messageContextMenu: root.messageStore.messageContextMenu
|
|
|
|
|
// isCurrentUser: root.messageStore.isCurrentUser
|
|
|
|
|
// profileImage: root.messageStore.profileImageSource
|
|
|
|
|
// isMessage: root.messageStore.isMessage
|
|
|
|
|
// identiconImageSource: root.messageStore.identicon
|
|
|
|
|
onClickMessage: {
|
|
|
|
|
parent.parent.parent.parent.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly, hideEmojiPicker, isReply);
|
|
|
|
|
}
|
2021-01-25 20:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UsernameLabel {
|
|
|
|
|
id: chatName
|
2021-06-29 14:49:32 +00:00
|
|
|
|
visible: !isEdit && isMessage && headerRepeatCondition
|
2021-01-25 20:50:42 +00:00
|
|
|
|
anchors.leftMargin: root.chatHorizontalPadding
|
|
|
|
|
anchors.top: chatImage.top
|
|
|
|
|
anchors.left: chatImage.right
|
2021-10-01 15:58:36 +00:00
|
|
|
|
// messageContextMenu: root.messageStore.messageContextMenu
|
|
|
|
|
// isCurrentUser: root.messageStore.isCurrentUser
|
|
|
|
|
// localName: root.messageStore.localName
|
|
|
|
|
// userName: root.messageStore.userName
|
|
|
|
|
// displayUserName: root.messageStore.displayUserName
|
|
|
|
|
onClickMessage: {
|
|
|
|
|
parent.parent.parent.parent.clickMessage(true, false, false, null, false, false, false);
|
|
|
|
|
}
|
2021-01-25 20:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
|
ChatTimePanel {
|
2021-02-01 18:40:55 +00:00
|
|
|
|
id: chatTime
|
2021-06-29 14:49:32 +00:00
|
|
|
|
visible: !isEdit && headerRepeatCondition
|
2021-02-01 18:40:55 +00:00
|
|
|
|
anchors.verticalCenter: chatName.verticalCenter
|
|
|
|
|
anchors.left: chatName.right
|
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
|
color: Style.current.secondaryText
|
2021-10-21 00:41:54 +00:00
|
|
|
|
//timestamp: timestamp
|
2021-02-01 18:40:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-29 14:49:32 +00:00
|
|
|
|
Loader {
|
|
|
|
|
id: editMessageLoader
|
|
|
|
|
active: isEdit
|
|
|
|
|
anchors.top: chatReply.active ? chatReply.bottom : parent.top
|
|
|
|
|
anchors.left: chatImage.right
|
|
|
|
|
anchors.leftMargin: root.chatHorizontalPadding
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: root.chatHorizontalPadding
|
|
|
|
|
height: (item !== null && typeof(item)!== 'undefined')? item.height: 0
|
2021-08-24 14:14:19 +00:00
|
|
|
|
property string sourceText
|
|
|
|
|
|
|
|
|
|
onActiveChanged: {
|
|
|
|
|
if (!active) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let mentionsMap = new Map()
|
|
|
|
|
let index = 0
|
|
|
|
|
while (true) {
|
|
|
|
|
index = message.indexOf("<a href=", index)
|
|
|
|
|
if (index < 0) {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
let endIndex = message.indexOf("</a>", index)
|
|
|
|
|
if (endIndex < 0) {
|
|
|
|
|
index += 8 // "<a href="
|
|
|
|
|
continue
|
|
|
|
|
}
|
2021-10-01 15:58:36 +00:00
|
|
|
|
let addrIndex = rmessage.indexOf("0x", index + 8)
|
2021-08-24 14:14:19 +00:00
|
|
|
|
if (addrIndex < 0) {
|
|
|
|
|
index += 8 // "<a href="
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
let addrEndIndex = message.indexOf('"', addrIndex)
|
|
|
|
|
if (addrEndIndex < 0) {
|
|
|
|
|
index += 8 // "<a href="
|
|
|
|
|
continue
|
|
|
|
|
}
|
2021-09-24 11:40:02 +00:00
|
|
|
|
const address = '@' + message.substring(addrIndex, addrEndIndex)
|
|
|
|
|
const linkTag = message.substring(index, endIndex + 5)
|
|
|
|
|
const linkText = linkTag.replace(/(<([^>]+)>)/ig,"").trim()
|
|
|
|
|
const atSymbol = linkText.startsWith("@") ? '' : '@'
|
|
|
|
|
const mentionTag = Constants.mentionSpanTag + atSymbol + linkText + '</span> '
|
|
|
|
|
mentionsMap.set(address, mentionTag)
|
2021-08-24 14:14:19 +00:00
|
|
|
|
index += linkTag.length
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sourceText = plainText
|
|
|
|
|
for (let [key, value] of mentionsMap) {
|
|
|
|
|
sourceText = sourceText.replace(new RegExp(key, 'g'), value)
|
|
|
|
|
}
|
|
|
|
|
sourceText = sourceText.replace(/\n/g, "<br />")
|
|
|
|
|
sourceText = Utils.getMessageWithStyle(sourceText, appSettings.useCompactMode, isCurrentUser)
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-29 14:49:32 +00:00
|
|
|
|
sourceComponent: Item {
|
|
|
|
|
id: editText
|
|
|
|
|
height: childrenRect.height
|
2021-08-02 13:38:03 +00:00
|
|
|
|
|
|
|
|
|
property bool suggestionsOpened: false
|
|
|
|
|
Keys.onEscapePressed: {
|
|
|
|
|
if (!suggestionsOpened) {
|
|
|
|
|
cancelBtn.clicked()
|
|
|
|
|
}
|
|
|
|
|
suggestionsOpened = false
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-29 14:49:32 +00:00
|
|
|
|
StatusChatInput {
|
2021-08-02 13:38:03 +00:00
|
|
|
|
id: editTextInput
|
2021-06-29 14:49:32 +00:00
|
|
|
|
chatInputPlaceholder: qsTrId("type-a-message-")
|
2021-10-21 22:39:53 +00:00
|
|
|
|
chatType: root.store.chatsModelInst.channelView.activeChannel.chatType
|
2021-06-29 14:49:32 +00:00
|
|
|
|
isEdit: true
|
2021-08-24 14:14:19 +00:00
|
|
|
|
textInput.text: editMessageLoader.sourceText
|
2021-08-02 13:38:03 +00:00
|
|
|
|
onSendMessage: {
|
|
|
|
|
saveBtn.clicked()
|
|
|
|
|
}
|
|
|
|
|
suggestions.onVisibleChanged: {
|
|
|
|
|
if (suggestions.visible) {
|
|
|
|
|
editText.suggestionsOpened = true
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-29 14:49:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 15:07:13 +00:00
|
|
|
|
StatusQControls.StatusFlatButton {
|
2021-06-29 14:49:32 +00:00
|
|
|
|
id: cancelBtn
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
|
|
|
|
anchors.top: editTextInput.bottom
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Cancel"
|
|
|
|
|
text: qsTrId("browsing-cancel")
|
2021-06-29 14:49:32 +00:00
|
|
|
|
onClicked: {
|
|
|
|
|
isEdit = false
|
|
|
|
|
editTextInput.textInput.text = Emoji.parse(message)
|
2021-08-02 13:38:03 +00:00
|
|
|
|
ensureMessageFullyVisibleTimer.start()
|
2021-06-29 14:49:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 15:07:13 +00:00
|
|
|
|
StatusQControls.StatusButton {
|
2021-06-29 14:49:32 +00:00
|
|
|
|
id: saveBtn
|
|
|
|
|
anchors.left: cancelBtn.right
|
|
|
|
|
anchors.leftMargin: Style.current.halfPadding
|
|
|
|
|
anchors.top: editTextInput.bottom
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Save"
|
|
|
|
|
text: qsTrId("save")
|
2021-08-02 13:38:03 +00:00
|
|
|
|
enabled: editTextInput.textInput.text.trim().length > 0
|
2021-06-29 14:49:32 +00:00
|
|
|
|
onClicked: {
|
2021-10-21 22:39:53 +00:00
|
|
|
|
let msg = root.store.chatsModelInst.plainText(Emoji.deparse(editTextInput.textInput.text))
|
2021-06-29 14:49:32 +00:00
|
|
|
|
if (msg.length > 0){
|
|
|
|
|
msg = chatInput.interpretMessage(msg)
|
|
|
|
|
isEdit = false
|
2021-10-21 22:39:53 +00:00
|
|
|
|
root.store.chatsModelInst.messageView.editMessage(messageId, contentType == Constants.editType ? replaces : messageId, msg);
|
2021-06-29 14:49:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-01 18:40:55 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: messageContent
|
2021-04-20 15:25:00 +00:00
|
|
|
|
height: childrenRect.height + (isEmoji ? 2 : 0)
|
2021-04-23 15:49:05 +00:00
|
|
|
|
anchors.top: chatName.visible ? chatName.bottom :
|
2021-05-14 17:23:27 +00:00
|
|
|
|
chatReply.active ? chatReply.bottom :
|
|
|
|
|
pinnedRectangleLoader.active ? pinnedRectangleLoader.bottom : parent.top
|
2021-01-25 20:50:42 +00:00
|
|
|
|
anchors.left: chatImage.right
|
|
|
|
|
anchors.leftMargin: root.chatHorizontalPadding
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: root.chatHorizontalPadding
|
2021-06-29 14:49:32 +00:00
|
|
|
|
visible: !isEdit
|
2021-08-02 13:38:03 +00:00
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
|
ChatTextView {
|
2021-02-01 18:40:55 +00:00
|
|
|
|
id: chatText
|
2021-10-21 22:39:53 +00:00
|
|
|
|
store: root.store
|
2021-10-01 15:58:36 +00:00
|
|
|
|
messageStore: root.messageStore
|
2021-09-06 12:19:57 +00:00
|
|
|
|
readonly property int leftPadding: chatImage.anchors.leftMargin + chatImage.width + root.chatHorizontalPadding
|
|
|
|
|
visible: {
|
|
|
|
|
const urls = root.linkUrls.split(" ")
|
|
|
|
|
if (urls.length === 1 && Utils.hasImageExtension(urls[0]) && appSettings.displayChatImages) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return isText || isEmoji
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-23 15:49:05 +00:00
|
|
|
|
anchors.top: parent.top
|
2021-04-20 15:25:00 +00:00
|
|
|
|
anchors.topMargin: isEmoji ? 2 : 0
|
2021-02-01 18:40:55 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
// using a padding instead of a margin let's us select text more easily
|
|
|
|
|
anchors.leftMargin: -leftPadding
|
|
|
|
|
textField.leftPadding: leftPadding
|
|
|
|
|
textField.rightPadding: Style.current.bigPadding
|
2021-09-27 12:08:55 +00:00
|
|
|
|
|
|
|
|
|
onLinkActivated: {
|
|
|
|
|
if (activityCenterMessage) {
|
|
|
|
|
clickMessage(false, isSticker, false)
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-01 18:40:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
id: chatImageContent
|
|
|
|
|
active: isImage
|
2021-04-23 15:49:05 +00:00
|
|
|
|
anchors.top: parent.top
|
2021-04-30 14:45:13 +00:00
|
|
|
|
anchors.topMargin: active ? 6 : 0
|
2021-02-01 18:40:55 +00:00
|
|
|
|
z: 51
|
|
|
|
|
sourceComponent: Component {
|
2021-08-30 12:42:11 +00:00
|
|
|
|
StatusChatImage {
|
2021-10-01 15:58:36 +00:00
|
|
|
|
imageSource: profileImageSource
|
2021-02-01 18:40:55 +00:00
|
|
|
|
imageWidth: 200
|
2021-08-16 09:11:43 +00:00
|
|
|
|
onClicked: {
|
2021-08-25 20:31:00 +00:00
|
|
|
|
if (mouse.button === Qt.LeftButton) {
|
2021-10-01 15:58:36 +00:00
|
|
|
|
root.messageStore.imageClick(image)
|
2021-08-16 09:11:43 +00:00
|
|
|
|
}
|
2021-08-25 20:31:00 +00:00
|
|
|
|
else if (mouse.button === Qt.RightButton) {
|
|
|
|
|
// Set parent, X & Y positions for the messageContextMenu
|
|
|
|
|
messageContextMenu.parent = root
|
|
|
|
|
messageContextMenu.setXPosition = function() { return (mouse.x)}
|
|
|
|
|
messageContextMenu.setYPosition = function() { return (mouse.y)}
|
2021-08-16 09:11:43 +00:00
|
|
|
|
root.clickMessage(false, false, true, image, false, true, false, true, imageSource)
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-01 18:40:55 +00:00
|
|
|
|
container: root.container
|
|
|
|
|
}
|
2020-09-30 18:01:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
|
|
2021-02-01 18:40:55 +00:00
|
|
|
|
Loader {
|
|
|
|
|
id: stickerLoader
|
|
|
|
|
active: contentType === Constants.stickerType
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: active ? Style.current.halfPadding : 0
|
|
|
|
|
sourceComponent: Component {
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: stickerContainer
|
|
|
|
|
color: Style.current.transparent
|
2021-04-14 15:32:35 +00:00
|
|
|
|
border.color: root.isHovered ? Qt.darker(Style.current.border, 1.1) : Style.current.border
|
2021-02-01 18:40:55 +00:00
|
|
|
|
border.width: 1
|
|
|
|
|
radius: 16
|
|
|
|
|
width: stickerId.width + 2 * root.chatVerticalPadding
|
|
|
|
|
height: stickerId.height + 2 * root.chatVerticalPadding
|
|
|
|
|
|
2021-08-30 12:42:11 +00:00
|
|
|
|
StatusSticker {
|
2021-02-01 18:40:55 +00:00
|
|
|
|
id: stickerId
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: root.chatVerticalPadding
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: root.chatVerticalPadding
|
|
|
|
|
contentType: root.contentType
|
2021-10-01 15:58:36 +00:00
|
|
|
|
stickerData: root.messageStore.sticker
|
2021-08-30 12:42:11 +00:00
|
|
|
|
onLoaded: {
|
2021-10-01 15:58:36 +00:00
|
|
|
|
root.messageStore.scrollToBottom(true, root.container)
|
2021-08-30 12:42:11 +00:00
|
|
|
|
}
|
2021-02-01 18:40:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageMouseArea {
|
|
|
|
|
id: messageMouseArea
|
|
|
|
|
anchors.fill: stickerLoader.active ? stickerLoader : chatText
|
2021-06-10 19:20:43 +00:00
|
|
|
|
z: activityCenterMessage ? chatText.z + 1 : chatText.z -1
|
2021-10-01 15:58:36 +00:00
|
|
|
|
messageContextMenu: root.messageContextMenu
|
|
|
|
|
isActivityCenterMessage: activityCenterMessage
|
|
|
|
|
onClickMessage: {
|
|
|
|
|
parent.parent.parent.parent.parent.clickMessage(isProfileClick, isSticker, isImage);
|
|
|
|
|
}
|
|
|
|
|
onSetMessageActive: {
|
|
|
|
|
root.messageStore.setMessageActive(messageId, active);
|
|
|
|
|
}
|
2021-02-01 18:40:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
id: linksLoader
|
|
|
|
|
active: !!root.linkUrls
|
|
|
|
|
anchors.top: chatText.bottom
|
|
|
|
|
anchors.topMargin: active ? Style.current.halfPadding : 0
|
|
|
|
|
|
|
|
|
|
sourceComponent: Component {
|
2021-10-01 15:58:36 +00:00
|
|
|
|
LinksMessageView {
|
2021-10-21 22:39:53 +00:00
|
|
|
|
store: root.store
|
2021-02-01 18:40:55 +00:00
|
|
|
|
linkUrls: root.linkUrls
|
2021-01-25 20:50:42 +00:00
|
|
|
|
container: root.container
|
2021-02-01 18:40:55 +00:00
|
|
|
|
isCurrentUser: root.isCurrentUser
|
2021-01-25 20:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
|
|
2021-02-01 18:40:55 +00:00
|
|
|
|
Loader {
|
|
|
|
|
id: audioPlayerLoader
|
|
|
|
|
active: isAudio
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: active ? Style.current.halfPadding : 0
|
2020-07-15 21:04:14 +00:00
|
|
|
|
|
2021-02-01 18:40:55 +00:00
|
|
|
|
sourceComponent: Component {
|
2021-10-01 15:58:36 +00:00
|
|
|
|
AudioPlayerPanel {
|
2021-02-01 18:40:55 +00:00
|
|
|
|
audioSource: audio
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-16 14:51:12 +00:00
|
|
|
|
|
2021-02-01 18:40:55 +00:00
|
|
|
|
Loader {
|
|
|
|
|
id: transactionBubbleLoader
|
|
|
|
|
active: contentType === Constants.transactionType
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: active ? (chatName.visible ? 4 : 6) : 0
|
|
|
|
|
sourceComponent: Component {
|
2021-10-21 22:39:53 +00:00
|
|
|
|
TransactionBubbleView {
|
|
|
|
|
store: root.store
|
2021-10-01 15:58:36 +00:00
|
|
|
|
}
|
2021-02-01 18:40:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-30 14:45:13 +00:00
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
|
active: contentType === Constants.communityInviteType
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: active ? 8 : 0
|
|
|
|
|
sourceComponent: Component {
|
|
|
|
|
id: invitationBubble
|
2021-10-21 00:41:54 +00:00
|
|
|
|
InvitationBubbleView {
|
|
|
|
|
store: root.store
|
2021-04-30 14:45:13 +00:00
|
|
|
|
communityId: container.communityId
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-25 20:50:42 +00:00
|
|
|
|
}
|
2020-07-14 15:35:21 +00:00
|
|
|
|
|
2021-02-01 18:40:55 +00:00
|
|
|
|
|
2021-01-25 20:50:42 +00:00
|
|
|
|
Retry {
|
|
|
|
|
id: retry
|
2021-02-01 18:40:55 +00:00
|
|
|
|
anchors.left: chatTime.visible ? chatTime.right : messageContent.left
|
|
|
|
|
anchors.leftMargin: chatTime.visible ? chatHorizontalPadding : 0
|
2021-09-21 03:25:50 +00:00
|
|
|
|
anchors.top: chatTime.visible ? chatTime.top : messageContent.bottom
|
2021-02-01 18:40:55 +00:00
|
|
|
|
anchors.topMargin: chatTime.visible ? 0 : -4
|
2021-09-21 03:25:50 +00:00
|
|
|
|
anchors.bottom: chatTime.visible ? chatTime.bottom : undefined
|
2021-10-01 15:58:36 +00:00
|
|
|
|
isCurrentUser: root.isCurrentUser
|
|
|
|
|
onClicked: {
|
|
|
|
|
root.store.chatsModelInst.messageView.resendMessage(chatId, messageId)
|
|
|
|
|
}
|
2020-10-23 19:46:44 +00:00
|
|
|
|
}
|
2021-02-01 18:40:55 +00:00
|
|
|
|
}
|
2020-10-23 19:46:44 +00:00
|
|
|
|
|
2021-02-01 18:40:55 +00:00
|
|
|
|
Loader {
|
2021-06-11 17:41:59 +00:00
|
|
|
|
active: !activityCenterMessage && (hasMention || pinnedMessage)
|
2021-02-01 18:40:55 +00:00
|
|
|
|
height: messageContainer.height
|
|
|
|
|
anchors.left: messageContainer.left
|
2021-05-25 19:34:46 +00:00
|
|
|
|
anchors.top: messageContainer.top
|
2020-07-30 16:07:41 +00:00
|
|
|
|
|
2021-02-01 18:40:55 +00:00
|
|
|
|
sourceComponent: Component {
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: mentionBorder
|
2021-05-25 19:34:46 +00:00
|
|
|
|
color: pinnedMessage ? Style.current.pinnedMessageBorder : Style.current.mentionColor
|
2021-02-01 18:40:55 +00:00
|
|
|
|
width: 2
|
|
|
|
|
height: parent.height
|
2020-09-30 18:45:45 +00:00
|
|
|
|
}
|
2020-07-30 16:07:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-12 15:01:03 +00:00
|
|
|
|
|
2021-02-09 20:40:39 +00:00
|
|
|
|
HoverHandler {
|
2021-06-10 19:20:43 +00:00
|
|
|
|
enabled: !activityCenterMessage &&
|
|
|
|
|
(forceHoverHandler || (typeof messageContextMenu !== "undefined" && typeof profilePopupOpened !== "undefined" && !messageContextMenu.opened && !profilePopupOpened && !popupOpened))
|
2021-10-01 15:58:36 +00:00
|
|
|
|
onHoveredChanged: {
|
|
|
|
|
root.messageStore.setHovered(messageId, hovered);
|
|
|
|
|
}
|
2021-01-25 20:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-12 15:01:03 +00:00
|
|
|
|
Loader {
|
|
|
|
|
id: emojiReactionLoader
|
2021-02-01 20:37:50 +00:00
|
|
|
|
active: emojiReactionsModel.length
|
2021-01-25 20:50:42 +00:00
|
|
|
|
anchors.bottom: messageContainer.bottom
|
2021-04-30 14:45:13 +00:00
|
|
|
|
anchors.bottomMargin: Style.current.halfPadding
|
2021-01-25 20:50:42 +00:00
|
|
|
|
anchors.left: messageContainer.left
|
|
|
|
|
anchors.leftMargin: messageContainer.chatText.textField.leftPadding
|
2020-08-12 15:01:03 +00:00
|
|
|
|
|
2020-09-30 18:45:45 +00:00
|
|
|
|
sourceComponent: Component {
|
2021-10-01 15:58:36 +00:00
|
|
|
|
EmojiReactionsPanel {
|
2021-08-25 20:31:00 +00:00
|
|
|
|
id: emojiRect
|
2021-10-01 15:58:36 +00:00
|
|
|
|
// emojiReactionsModel: root.messageStore.emojiReactionsModel
|
|
|
|
|
onHoverChanged: {
|
|
|
|
|
root.messageStore.setHovered(messageId, hovered)
|
|
|
|
|
}
|
|
|
|
|
// isMessageActive: root.messageStore.isMessageActive
|
2021-07-16 15:02:47 +00:00
|
|
|
|
onAddEmojiClicked: {
|
|
|
|
|
root.addEmoji(false, false, false, null, true, false);
|
2021-08-25 20:31:00 +00:00
|
|
|
|
// Set parent, X & Y positions for the messageContextMenu
|
|
|
|
|
messageContextMenu.parent = emojiReactionLoader
|
|
|
|
|
messageContextMenu.setXPosition = function() { return (messageContextMenu.parent.x + 4)}
|
|
|
|
|
messageContextMenu.setYPosition = function() { return (-messageContextMenu.height - 4)}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
}
|
2021-10-21 22:39:53 +00:00
|
|
|
|
onToggleReaction: root.store.chatsModelInst.toggleReaction(messageId, emojiID)
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
|
|
|
|
onSetMessageActive: {
|
|
|
|
|
root.messageStore.setMessageActive(messageId, active);;
|
|
|
|
|
}
|
2021-01-25 20:50:42 +00:00
|
|
|
|
}
|
2020-09-30 18:45:45 +00:00
|
|
|
|
}
|
2020-08-12 15:01:03 +00:00
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
|
}
|