2020-12-04 10:38:22 +00:00
|
|
|
import QtQuick 2.13
|
2020-07-15 21:04:14 +00:00
|
|
|
import "../../../../../shared"
|
|
|
|
import "../../../../../imports"
|
|
|
|
|
|
|
|
Item {
|
|
|
|
property var clickMessage: function () {}
|
|
|
|
property int chatHorizontalPadding: 12
|
|
|
|
property int chatVerticalPadding: 7
|
2020-12-07 23:38:53 +00:00
|
|
|
property string linkUrls: ""
|
|
|
|
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
|
2020-07-15 21:04:14 +00:00
|
|
|
|
2020-12-07 23:38:53 +00:00
|
|
|
id: root
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: authorCurrentMsg != authorPrevMsg ? Style.current.smallPadding : 0
|
|
|
|
height: childrenRect.height + this.anchors.topMargin
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
// FIXME @jonathanr: Adding this breaks the first line. Need to fix the height somehow
|
|
|
|
// DateGroup {
|
|
|
|
// id: dateGroupLbl
|
|
|
|
// }
|
|
|
|
|
|
|
|
UserImage {
|
|
|
|
id: chatImage
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
// anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
|
|
|
|
anchors.top: parent.top
|
|
|
|
}
|
|
|
|
|
|
|
|
UsernameLabel {
|
|
|
|
id: chatName
|
2020-12-07 23:38:53 +00:00
|
|
|
anchors.leftMargin: root.chatHorizontalPadding
|
2020-07-15 21:04:14 +00:00
|
|
|
// anchors.top: dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: chatImage.right
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatReply {
|
|
|
|
id: chatReply
|
|
|
|
// anchors.top: chatName.visible ? chatName.bottom : (dateGroupLbl.visible ? dateGroupLbl.bottom : parent.top)
|
|
|
|
anchors.top: chatName.visible ? chatName.bottom : parent.top
|
2020-12-07 23:38:53 +00:00
|
|
|
anchors.topMargin: chatName.visible && this.visible ? root.chatVerticalPadding : 0
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.left: chatImage.right
|
2020-12-07 23:38:53 +00:00
|
|
|
anchors.leftMargin: root.chatHorizontalPadding
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.right: parent.right
|
2020-12-07 23:38:53 +00:00
|
|
|
anchors.rightMargin: root.chatHorizontalPadding
|
2020-12-16 20:50:54 +00:00
|
|
|
container: root.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
|
|
|
chatHorizontalPadding: root.chatHorizontalPadding
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ChatText {
|
|
|
|
id: chatText
|
|
|
|
anchors.top: chatReply.bottom
|
2020-12-07 23:38:53 +00:00
|
|
|
anchors.topMargin: chatName.visible && this.visible ? root.chatVerticalPadding : 0
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.left: chatImage.right
|
2020-12-07 23:38:53 +00:00
|
|
|
anchors.leftMargin: root.chatHorizontalPadding
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.right: parent.right
|
2020-12-07 23:38:53 +00:00
|
|
|
anchors.rightMargin: root.chatHorizontalPadding
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
|
|
|
|
2020-07-20 17:34:20 +00:00
|
|
|
Loader {
|
2020-07-17 19:44:25 +00:00
|
|
|
id: chatImageContent
|
2020-07-20 17:34:20 +00:00
|
|
|
active: isImage
|
2020-09-30 18:16:16 +00:00
|
|
|
anchors.left: chatText.left
|
2020-07-23 18:20:57 +00:00
|
|
|
anchors.leftMargin: 8
|
|
|
|
anchors.top: chatReply.bottom
|
2020-11-27 15:38:58 +00:00
|
|
|
z: 51
|
|
|
|
|
2020-09-30 18:16:16 +00:00
|
|
|
sourceComponent: Component {
|
|
|
|
ChatImage {
|
|
|
|
imageSource: image
|
|
|
|
imageWidth: 200
|
2020-12-07 23:38:53 +00:00
|
|
|
onClicked: root.clickMessage(false, false, true, image)
|
2020-12-16 20:50:54 +00:00
|
|
|
container: root.container
|
2020-09-30 18:16:16 +00:00
|
|
|
}
|
2020-07-20 17:34:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 18:01:20 +00:00
|
|
|
Loader {
|
|
|
|
id: stickerLoader
|
|
|
|
active: contentType === Constants.stickerType
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.left: chatText.left
|
|
|
|
anchors.top: chatName.visible ? chatName.bottom : parent.top
|
2020-12-07 23:38:53 +00:00
|
|
|
anchors.topMargin: this.visible && chatName.visible ? root.chatVerticalPadding : 0
|
2020-07-15 21:04:14 +00:00
|
|
|
|
2020-09-30 18:01:20 +00:00
|
|
|
sourceComponent: Component {
|
|
|
|
Rectangle {
|
|
|
|
id: stickerContainer
|
|
|
|
color: Style.current.transparent
|
|
|
|
border.color: Style.current.grey
|
|
|
|
border.width: 1
|
|
|
|
radius: 16
|
2020-12-07 23:38:53 +00:00
|
|
|
width: stickerId.width + 2 * root.chatVerticalPadding
|
|
|
|
height: stickerId.height + 2 * root.chatVerticalPadding
|
2020-09-30 18:01:20 +00:00
|
|
|
|
|
|
|
Sticker {
|
|
|
|
id: stickerId
|
|
|
|
anchors.top: parent.top
|
2020-12-07 23:38:53 +00:00
|
|
|
anchors.topMargin: root.chatVerticalPadding
|
2020-09-30 18:01:20 +00:00
|
|
|
anchors.left: parent.left
|
2020-12-07 23:38:53 +00:00
|
|
|
anchors.leftMargin: root.chatVerticalPadding
|
|
|
|
contentType: root.contentType
|
2020-12-16 20:50:54 +00:00
|
|
|
container: root.container
|
2020-09-30 18:01:20 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageMouseArea {
|
2020-09-30 18:01:20 +00:00
|
|
|
anchors.fill: stickerLoader.active ? stickerLoader : chatText
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO show date for not the first messsage (on hover maybe)
|
|
|
|
ChatTime {
|
|
|
|
id: chatTime
|
|
|
|
visible: authorCurrentMsg != authorPrevMsg
|
|
|
|
anchors.verticalCenter: chatName.verticalCenter
|
|
|
|
anchors.left: chatName.right
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
}
|
|
|
|
|
|
|
|
SentMessage {
|
|
|
|
id: sentMessage
|
2020-11-12 14:17:29 +00:00
|
|
|
visible: isCurrentUser && !timeout && !isExpired && isMessage && outgoingStatus !== "sent"
|
2020-07-15 21:04:14 +00:00
|
|
|
anchors.verticalCenter: chatTime.verticalCenter
|
|
|
|
anchors.left: chatTime.right
|
2020-07-22 18:45:03 +00:00
|
|
|
anchors.leftMargin: 8
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
2020-07-16 14:51:12 +00:00
|
|
|
|
2020-07-14 15:35:21 +00:00
|
|
|
Retry {
|
|
|
|
id: retry
|
|
|
|
anchors.right: chatTime.right
|
|
|
|
anchors.rightMargin: 5
|
|
|
|
}
|
|
|
|
|
2020-10-23 19:46:44 +00:00
|
|
|
Loader {
|
|
|
|
id: linksLoader
|
2020-12-07 23:38:53 +00:00
|
|
|
active: !!root.linkUrls
|
2020-10-23 19:46:44 +00:00
|
|
|
anchors.left: chatText.left
|
|
|
|
anchors.leftMargin: 8
|
|
|
|
anchors.top: chatText.bottom
|
|
|
|
|
|
|
|
sourceComponent: Component {
|
2020-12-07 23:38:53 +00:00
|
|
|
LinksMessage {
|
|
|
|
linkUrls: root.linkUrls
|
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
|
|
|
container: root.container
|
|
|
|
isCurrentUser: root.isCurrentUser
|
2020-12-07 23:38:53 +00:00
|
|
|
}
|
2020-10-23 19:46:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-30 16:07:41 +00:00
|
|
|
Loader {
|
|
|
|
id: audioPlayerLoader
|
|
|
|
active: isAudio
|
|
|
|
anchors.top: chatName.visible ? chatName.bottom : parent.top
|
|
|
|
anchors.left: chatImage.right
|
|
|
|
|
2020-09-30 18:45:45 +00:00
|
|
|
sourceComponent: Component {
|
|
|
|
AudioPlayer {
|
|
|
|
audioSource: audio
|
|
|
|
}
|
2020-07-30 16:07:41 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-12 15:01:03 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: emojiReactionLoader
|
|
|
|
active: emojiReactions !== ""
|
|
|
|
anchors.top: chatText.bottom
|
|
|
|
anchors.left: chatText.left
|
2020-09-30 20:40:54 +00:00
|
|
|
anchors.topMargin: active ? 2 : 0
|
2020-08-12 15:01:03 +00:00
|
|
|
|
2020-09-30 18:45:45 +00:00
|
|
|
sourceComponent: Component {
|
|
|
|
EmojiReactions {}
|
|
|
|
}
|
2020-08-12 15:01:03 +00:00
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|