status-desktop/ui/app/AppLayouts/Chat/controls/MessageBorder.qml

96 lines
2.7 KiB
QML
Raw Normal View History

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
import QtQuick 2.13
import QtGraphicalEffects 1.13
import QtQuick.Layouts 1.13
import utils 1.0
import shared 1.0
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
Item {
id: root
default property alias inner: contents.children
property bool isCurrentUser: false
readonly property int smallCorner: Style.current.radius / 2
readonly property int bigCorner: Style.current.radius * 2
readonly property int fakeCornerSize: bigCorner * 2
Rectangle {
width: parent.width + 2
height: parent.height + 2
anchors.top: parent.top
anchors.left: parent.left
anchors.topMargin: -1
anchors.leftMargin: -1
radius: root.bigCorner
border.width: 2
border.color: Style.current.border
}
Rectangle {
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.bottomMargin: -1
anchors.leftMargin: -1
width: root.fakeCornerSize
height: root.fakeCornerSize
radius: root.smallCorner
visible: !root.isCurrentUser
border.width: 2
border.color: Style.current.border
}
Rectangle {
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.bottomMargin: -1
anchors.rightMargin: -1
width: root.fakeCornerSize
height: root.fakeCornerSize
radius: root.smallCorner
visible: root.isCurrentUser
border.width: 2
border.color: Style.current.border
}
Rectangle {
anchors.fill: parent
color: Style.current.background
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Item {
width: root.width
height: root.height
Rectangle {
anchors.top: parent.top
anchors.left: parent.left
width: parent.width
height: parent.height
radius: root.bigCorner
}
Rectangle {
anchors.bottom: parent.bottom
anchors.left: parent.left
width: root.fakeCornerSize
height: root.fakeCornerSize
radius: root.smallCorner
visible: !root.isCurrentUser
}
Rectangle {
anchors.bottom: parent.bottom
anchors.right: parent.right
width: root.fakeCornerSize
height: root.fakeCornerSize
radius: root.smallCorner
visible: root.isCurrentUser
}
}
}
Item {
id: contents
width: root.width
height: root.height
}
}
}