2020-12-10 20:59:00 +00:00
|
|
|
import QtQuick 2.14
|
2020-07-15 21:04:14 +00:00
|
|
|
import "../../../../../shared"
|
|
|
|
import "../../../../../imports"
|
|
|
|
|
2020-09-30 20:40:54 +00:00
|
|
|
Loader {
|
|
|
|
property int textFieldWidth: item ? item.textField.width : 0
|
2020-12-10 20:59:00 +00:00
|
|
|
property int authorWidth: item ? item.authorMetrics.width : 0
|
|
|
|
|
2020-07-20 21:26:29 +00:00
|
|
|
property bool longReply: false
|
2020-09-22 14:30:49 +00:00
|
|
|
property color elementsColor: isCurrentUser ? Style.current.chatReplyCurrentUser : Style.current.secondaryText
|
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 int chatHorizontalPadding
|
2020-07-20 21:26:29 +00:00
|
|
|
|
2020-09-30 20:40:54 +00:00
|
|
|
id: root
|
|
|
|
active: responseTo != "" && replyMessageIndex > -1
|
2020-07-15 21:04:14 +00:00
|
|
|
|
2020-09-30 20:40:54 +00:00
|
|
|
sourceComponent: Component {
|
|
|
|
Rectangle {
|
|
|
|
property alias textField: lblReplyMessage
|
2020-12-10 20:59:00 +00:00
|
|
|
property alias authorMetrics: txtAuthorMetrics
|
2020-07-17 19:44:25 +00:00
|
|
|
|
2020-09-30 20:40:54 +00:00
|
|
|
id: chatReply
|
|
|
|
visible: responseTo != "" && replyMessageIndex > -1
|
|
|
|
// childrenRect.height shows a binding loop for soem reason, so we use heights instead
|
|
|
|
height: this.visible ? lblReplyAuthor.height + ((repliedMessageType === Constants.imageType ? imgReplyImage.height : lblReplyMessage.height) + 5 + 8) : 0
|
|
|
|
color: Style.current.transparent
|
|
|
|
|
2020-12-10 20:59:00 +00:00
|
|
|
TextMetrics {
|
|
|
|
id: txtAuthorMetrics
|
|
|
|
font: lblReplyAuthor.font
|
|
|
|
text: lblReplyAuthor.text
|
|
|
|
}
|
|
|
|
|
2020-09-30 20:40:54 +00:00
|
|
|
StyledTextEdit {
|
|
|
|
id: lblReplyAuthor
|
|
|
|
text: "↳" + repliedMessageAuthor
|
|
|
|
color: root.elementsColor
|
|
|
|
readOnly: true
|
|
|
|
selectByMouse: true
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
|
2020-09-30 20:40:54 +00:00
|
|
|
ChatImage {
|
|
|
|
id: imgReplyImage
|
|
|
|
visible: repliedMessageType == Constants.imageType
|
|
|
|
imageWidth: 50
|
|
|
|
imageSource: repliedMessageImage
|
|
|
|
anchors.top: lblReplyAuthor.bottom
|
|
|
|
anchors.topMargin: 5
|
|
|
|
anchors.left: parent.left
|
|
|
|
chatHorizontalPadding: 0
|
2020-12-16 20:50:54 +00:00
|
|
|
container: root.container
|
2020-09-30 20:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StyledTextEdit {
|
|
|
|
id: lblReplyMessage
|
|
|
|
visible: repliedMessageType != Constants.imageType
|
|
|
|
anchors.top: lblReplyAuthor.bottom
|
|
|
|
anchors.topMargin: 5
|
2020-11-26 17:35:13 +00:00
|
|
|
text: `<style type="text/css">`+
|
2020-11-26 14:42:10 +00:00
|
|
|
`a {`+
|
|
|
|
`color: ${isCurrentUser && !appSettings.compactMode ? Style.current.white : Style.current.textColor};`+
|
|
|
|
`}`+
|
|
|
|
`a.mention {`+
|
|
|
|
`color: ${isCurrentUser ? Style.current.cyan : Style.current.turquoise};`+
|
|
|
|
`}`+
|
|
|
|
`</style>`+
|
|
|
|
`</head>`+
|
|
|
|
`<body>`+
|
2020-11-26 17:35:13 +00:00
|
|
|
`${Emoji.parse(Utils.linkifyAndXSS(repliedMessageContent), "26x26")}`+
|
2020-11-26 14:42:10 +00:00
|
|
|
`</body>`+
|
|
|
|
`</html>`
|
2020-09-30 20:40:54 +00:00
|
|
|
textFormat: Text.RichText
|
|
|
|
color: root.elementsColor
|
|
|
|
readOnly: true
|
|
|
|
selectByMouse: true
|
|
|
|
wrapMode: Text.Wrap
|
2021-01-04 18:24:49 +00:00
|
|
|
font.pixelSize: Style.current.secondaryTextFontSize
|
2020-09-30 20:40:54 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: root.longReply ? parent.right : undefined
|
|
|
|
z: 51
|
|
|
|
}
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
anchors.top: repliedMessageType == Constants.imageType ? imgReplyImage.bottom : lblReplyMessage.bottom
|
|
|
|
anchors.topMargin: repliedMessageType == Constants.imageType ? 15 : 8
|
|
|
|
anchors.left: lblReplyMessage.left
|
|
|
|
anchors.right: lblReplyMessage.right
|
2020-12-11 18:15:40 +00:00
|
|
|
anchors.rightMargin: root.chatHorizontalPadding
|
2020-09-30 20:40:54 +00:00
|
|
|
color: root.elementsColor
|
|
|
|
}
|
|
|
|
}
|
2020-07-15 21:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-30 20:40:54 +00:00
|
|
|
|