2023-02-03 13:05:32 +00:00
|
|
|
import QtQuick 2.15
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-18 14:05:30 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2023-09-18 10:30:19 +00:00
|
|
|
import StatusQ.Components 0.1
|
2021-10-18 14:05:30 +00:00
|
|
|
|
2023-10-13 13:36:07 +00:00
|
|
|
import shared.controls 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.status 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.panels 1.0
|
2022-01-25 12:56:53 +00:00
|
|
|
import shared.stores 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.controls.chat 1.0
|
2020-10-23 19:46:44 +00:00
|
|
|
|
2023-10-09 10:27:02 +00:00
|
|
|
Flow {
|
2020-12-07 23:38:53 +00:00
|
|
|
id: root
|
2022-10-07 12:17:09 +00:00
|
|
|
|
2023-09-13 09:12:47 +00:00
|
|
|
required property var store
|
|
|
|
required property var messageStore
|
2023-08-22 15:46:26 +00:00
|
|
|
|
2023-09-13 09:12:47 +00:00
|
|
|
required property var linkPreviewModel
|
|
|
|
required property var localUnfurlLinks
|
2022-09-20 14:14:58 +00:00
|
|
|
|
2023-09-13 09:12:47 +00:00
|
|
|
required property bool isCurrentUser
|
2022-08-31 08:32:08 +00:00
|
|
|
|
2023-10-09 12:41:27 +00:00
|
|
|
readonly property alias hoveredLink: linksRepeater.hoveredUrl
|
|
|
|
property string highlightLink: ""
|
|
|
|
|
2023-09-05 16:04:58 +00:00
|
|
|
signal imageClicked(var image, var mouse, var imageSource, string url)
|
2022-02-16 19:37:03 +00:00
|
|
|
|
2023-10-09 10:27:02 +00:00
|
|
|
spacing: 12
|
|
|
|
|
|
|
|
//TODO: remove once GIF previews are unfurled sender side
|
|
|
|
Repeater {
|
|
|
|
id: tempRepeater
|
|
|
|
visible: !RootStore.neverAskAboutUnfurlingAgain
|
|
|
|
model: linksModel
|
|
|
|
|
|
|
|
delegate: Loader {
|
|
|
|
id: tempLoader
|
|
|
|
|
|
|
|
required property var result
|
|
|
|
required property string link
|
|
|
|
required property int index
|
|
|
|
required property bool unfurl
|
|
|
|
required property bool success
|
|
|
|
required property bool isStatusDeepLink
|
|
|
|
readonly property bool isImage: result.contentType && result.contentType.startsWith("image/") ? true : false
|
|
|
|
readonly property bool isUserProfileLink: link.toLowerCase().startsWith(Constants.userLinkPrefix.toLowerCase())
|
|
|
|
readonly property string thumbnailUrl: result && result.thumbnailUrl ? result.thumbnailUrl : ""
|
|
|
|
readonly property string title: result && result.title ? result.title : ""
|
|
|
|
readonly property string hostname: result && result.site ? result.site : ""
|
|
|
|
readonly property bool animated: isImage && result.contentType === "image/gif" // TODO support more types of animated images?
|
|
|
|
|
|
|
|
StateGroup {
|
|
|
|
//Using StateGroup as a warkardound for https://bugreports.qt.io/browse/QTBUG-47796
|
|
|
|
id: linkPreviewLoaderState
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "askToEnableUnfurling"
|
|
|
|
when: !tempLoader.unfurl
|
|
|
|
PropertyChanges { target: tempLoader; sourceComponent: enableLinkComponent }
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "loadImage"
|
|
|
|
when: tempLoader.unfurl && tempLoader.isImage
|
|
|
|
PropertyChanges { target: tempLoader; sourceComponent: unfurledImageComponent }
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "userProfileLink"
|
|
|
|
when: unfurl && isUserProfileLink && isStatusDeepLink
|
|
|
|
PropertyChanges { target: tempLoader; sourceComponent: unfurledProfileLinkComponent }
|
|
|
|
}
|
|
|
|
// State {
|
|
|
|
// name: "statusInvitation"
|
|
|
|
// when: unfurl && isStatusDeepLink
|
|
|
|
// PropertyChanges { target: tempLoader; sourceComponent: invitationBubble }
|
|
|
|
// }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-23 19:46:44 +00:00
|
|
|
Repeater {
|
|
|
|
id: linksRepeater
|
2023-07-21 23:08:44 +00:00
|
|
|
|
2023-10-09 12:41:27 +00:00
|
|
|
property string hoveredUrl: ""
|
|
|
|
|
|
|
|
model: root.linkPreviewModel
|
2020-10-23 19:46:44 +00:00
|
|
|
delegate: Loader {
|
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
|
|
|
id: linkMessageLoader
|
2023-07-21 23:08:44 +00:00
|
|
|
// properties from the model
|
2023-10-13 13:36:07 +00:00
|
|
|
|
2023-07-21 23:08:44 +00:00
|
|
|
required property bool unfurled
|
2023-10-13 13:36:07 +00:00
|
|
|
required property bool empty
|
|
|
|
required property string url
|
|
|
|
required property bool immutable
|
|
|
|
required property int previewType
|
|
|
|
required property var standardPreview
|
|
|
|
required property var standardPreviewThumbnail
|
|
|
|
required property var statusContactPreview
|
|
|
|
required property var statusContactPreviewThumbnail
|
|
|
|
required property var statusCommunityPreview
|
|
|
|
required property var statusCommunityPreviewIcon
|
|
|
|
required property var statusCommunityPreviewBanner
|
|
|
|
required property var statusCommunityChannelPreview
|
|
|
|
required property var statusCommunityChannelCommunityPreview
|
|
|
|
required property var statusCommunityChannelCommunityPreviewIcon
|
|
|
|
required property var statusCommunityChannelCommunityPreviewBanner
|
|
|
|
|
|
|
|
readonly property string hostname: standardPreview ? standardPreview.hostname : ""
|
|
|
|
readonly property string title: standardPreview ? standardPreview.title : ""
|
|
|
|
readonly property string description: standardPreview ? standardPreview.description : ""
|
|
|
|
readonly property int standardLinkType: standardPreview ? standardPreview.linkType : ""
|
|
|
|
readonly property int thumbnailWidth: standardPreviewThumbnail ? standardPreviewThumbnail.width : ""
|
|
|
|
readonly property int thumbnailHeight: standardPreviewThumbnail ? standardPreviewThumbnail.height : ""
|
|
|
|
readonly property string thumbnailUrl: standardPreviewThumbnail ? standardPreviewThumbnail.url : ""
|
|
|
|
readonly property string thumbnailDataUri: standardPreviewThumbnail ? standardPreviewThumbnail.dataUri : ""
|
2023-08-22 15:46:26 +00:00
|
|
|
property bool animated: false
|
2023-07-21 23:08:44 +00:00
|
|
|
|
2023-02-03 13:05:32 +00:00
|
|
|
asynchronous: true
|
2023-10-13 13:36:07 +00:00
|
|
|
active: unfurled && !empty
|
2023-09-13 09:12:47 +00:00
|
|
|
|
2023-10-13 13:36:07 +00:00
|
|
|
StateGroup {
|
|
|
|
//Using StateGroup as a warkardound for https://bugreports.qt.io/browse/QTBUG-47796
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "standardLinkPreview"
|
|
|
|
when: linkMessageLoader.previewType === Constants.LinkPreviewType.Standard
|
|
|
|
PropertyChanges { target: linkMessageLoader; sourceComponent: standardLinkPreviewCard }
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "statusContactLinkPreview"
|
|
|
|
when: linkMessageLoader.previewType === Constants.LinkPreviewType.StatusContact
|
|
|
|
PropertyChanges { target: linkMessageLoader; sourceComponent: unfurledProfileLinkComponent }
|
2023-10-09 14:53:59 +00:00
|
|
|
}
|
2023-10-13 13:36:07 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: standardLinkPreviewCard
|
|
|
|
LinkPreviewCard {
|
|
|
|
leftTail: !root.isCurrentUser // WARNING: Is this by design?
|
|
|
|
bannerImageSource: standardPreviewThumbnail ? standardPreviewThumbnail.url : ""
|
|
|
|
title: standardPreview ? standardPreview.title : ""
|
|
|
|
description: standardPreview ? standardPreview.description : ""
|
|
|
|
footer: standardPreview ? standardPreview.hostname : ""
|
|
|
|
onClicked: (mouse) => {
|
|
|
|
switch (mouse.button) {
|
|
|
|
case Qt.RightButton:
|
|
|
|
root.imageClicked(unfurledLink, mouse, "", url) // request a dumb context menu with just "copy/open link" items
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
Global.openLinkWithConfirmation(url, hostname)
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: unfurledProfileLinkComponent
|
|
|
|
UserProfileCard {
|
|
|
|
id: unfurledProfileLink
|
|
|
|
|
|
|
|
leftTail: !root.isCurrentUser
|
|
|
|
userName: statusContactPreview && statusContactPreview.displayName ? statusContactPreview.displayName : ""
|
|
|
|
userPublicKey: statusContactPreview && statusContactPreview.publicKey ? statusContactPreview.publicKey : ""
|
|
|
|
userBio: statusContactPreview && statusContactPreview.description ? statusContactPreview.description : ""
|
|
|
|
userImage: statusContactPreviewThumbnail ? statusContactPreviewThumbnail.url : ""
|
|
|
|
ensVerified: false // not supported yet
|
|
|
|
onClicked: {
|
|
|
|
Global.openProfilePopup(userPublicKey)
|
2022-08-31 08:32:08 +00:00
|
|
|
}
|
2023-02-03 13:05:32 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-13 14:24:21 +00:00
|
|
|
|
2023-09-13 09:12:47 +00:00
|
|
|
//TODO: Remove this once we have gif support in new unfurling flow
|
2020-10-23 19:46:44 +00:00
|
|
|
Component {
|
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
|
|
|
id: unfurledImageComponent
|
2023-09-13 09:12:47 +00:00
|
|
|
CalloutCard {
|
2023-07-21 23:08:44 +00:00
|
|
|
implicitWidth: linkImage.width
|
|
|
|
implicitHeight: linkImage.height
|
2023-09-13 09:12:47 +00:00
|
|
|
leftTail: !root.isCurrentUser
|
2021-08-30 12:42:11 +00:00
|
|
|
StatusChatImageLoader {
|
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
|
|
|
id: linkImage
|
2023-02-03 13:05:32 +00:00
|
|
|
readonly property bool globalAnimationEnabled: root.messageStore.playAnimation
|
2023-10-09 14:53:59 +00:00
|
|
|
readonly property string urlLink: link
|
2023-02-03 13:05:32 +00:00
|
|
|
property bool localAnimationEnabled: true
|
2022-09-15 16:32:14 +00:00
|
|
|
objectName: "LinksMessageView_unfurledImageComponent_linkImage"
|
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
|
|
|
anchors.centerIn: parent
|
2023-08-22 07:26:54 +00:00
|
|
|
source: thumbnailUrl
|
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
|
|
|
imageWidth: 300
|
|
|
|
isCurrentUser: root.isCurrentUser
|
2023-02-03 13:05:32 +00:00
|
|
|
playing: globalAnimationEnabled && localAnimationEnabled
|
2022-10-07 12:17:09 +00:00
|
|
|
isOnline: root.store.mainModuleInst.isOnline
|
2023-02-03 13:05:32 +00:00
|
|
|
asynchronous: true
|
2023-10-09 14:53:59 +00:00
|
|
|
isAnimated: animated
|
2023-05-19 16:07:50 +00:00
|
|
|
onClicked: {
|
|
|
|
if (isAnimated && !playing)
|
|
|
|
localAnimationEnabled = true
|
|
|
|
else
|
2023-09-05 16:04:58 +00:00
|
|
|
root.imageClicked(linkImage.imageAlias, mouse, source, urlLink)
|
2023-05-19 16:07:50 +00:00
|
|
|
}
|
2023-04-26 15:33:24 +00:00
|
|
|
imageAlias.cache: localAnimationEnabled // GIFs can only loop/play properly with cache enabled
|
2023-02-03 13:05:32 +00:00
|
|
|
Loader {
|
|
|
|
width: 45
|
|
|
|
height: 38
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 12
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 12
|
|
|
|
active: linkImage.isAnimated && !linkImage.playing
|
|
|
|
sourceComponent: Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
color: "black"
|
|
|
|
radius: Style.current.radius
|
|
|
|
opacity: .4
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
text: "GIF"
|
|
|
|
font.pixelSize: 13
|
2023-02-28 15:00:10 +00:00
|
|
|
color: "white"
|
2023-02-03 13:05:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Timer {
|
|
|
|
id: animationPlayingTimer
|
|
|
|
interval: 10000
|
|
|
|
running: linkImage.isAnimated && linkImage.playing
|
|
|
|
onTriggered: { linkImage.localAnimationEnabled = false }
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-09-13 09:12:47 +00:00
|
|
|
// Code below can be dropped when New unfurling flow suppports GIFs.
|
2021-03-08 20:21:56 +00:00
|
|
|
Component {
|
|
|
|
id: invitationBubble
|
2021-10-21 00:41:54 +00:00
|
|
|
InvitationBubbleView {
|
2023-02-03 13:05:32 +00:00
|
|
|
property var invitationData: root.store.getLinkDataForStatusLinks(link)
|
2022-02-11 21:41:34 +00:00
|
|
|
store: root.store
|
2023-07-27 11:21:25 +00:00
|
|
|
communityId: invitationData && invitationData.communityData ? invitationData.communityData.communityId : ""
|
|
|
|
communityData: invitationData && invitationData.communityData ? invitationData.communityData : null
|
2021-03-08 20:21:56 +00:00
|
|
|
anchors.left: parent.left
|
2023-05-24 12:06:43 +00:00
|
|
|
visible: !!invitationData
|
|
|
|
loading: invitationData.fetching
|
2023-07-21 23:08:44 +00:00
|
|
|
onInvitationDataChanged: {
|
|
|
|
if (!invitationData)
|
|
|
|
linksModel.remove(index)
|
|
|
|
}
|
2023-02-03 13:05:32 +00:00
|
|
|
Connections {
|
2023-02-27 17:27:37 +00:00
|
|
|
enabled: !!invitationData && invitationData.fetching
|
2023-02-03 13:05:32 +00:00
|
|
|
target: root.store.communitiesModuleInst
|
|
|
|
function onCommunityAdded(communityId: string) {
|
|
|
|
if (communityId !== invitationData.communityId) return
|
|
|
|
invitationData = root.store.getLinkDataForStatusLinks(link)
|
|
|
|
}
|
|
|
|
}
|
2021-03-08 20:21:56 +00:00
|
|
|
}
|
|
|
|
}
|
2023-08-22 15:46:26 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
readonly property string uuid: Utils.uuid()
|
|
|
|
readonly property string whiteListedImgExtensions: Constants.acceptedImageExtensions.toString()
|
|
|
|
readonly property string whiteListedUrls: JSON.stringify(localAccountSensitiveSettings.whitelistedUnfurlingSites)
|
|
|
|
readonly property string getLinkPreviewDataId: {
|
|
|
|
if (root.localUnfurlLinks === "")
|
|
|
|
return ""
|
|
|
|
return root.messageStore.messageModule.getLinkPreviewData(root.localUnfurlLinks,
|
|
|
|
d.uuid,
|
|
|
|
whiteListedUrls,
|
|
|
|
whiteListedImgExtensions,
|
|
|
|
localAccountSensitiveSettings.displayChatImages)
|
|
|
|
}
|
|
|
|
onGetLinkPreviewDataIdChanged: {
|
|
|
|
linkFetchConnections.enabled = root.localUnfurlLinks !== ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Connections {
|
|
|
|
id: linkFetchConnections
|
|
|
|
enabled: false
|
|
|
|
target: root.messageStore.messageModule
|
|
|
|
function onLinkPreviewDataWasReceived(previewData, uuid) {
|
|
|
|
if (d.uuid !== uuid)
|
|
|
|
return
|
|
|
|
linkFetchConnections.enabled = false
|
|
|
|
try {
|
|
|
|
linksModel.rawData = JSON.parse(previewData)
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
console.warn("error parsing link preview data", previewData)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ListModel {
|
|
|
|
id: linksModel
|
|
|
|
property var rawData
|
|
|
|
onRawDataChanged: {
|
|
|
|
linksModel.clear()
|
|
|
|
rawData.links.forEach((link) => {
|
|
|
|
linksModel.append(link)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: enableLinkComponent
|
|
|
|
Rectangle {
|
|
|
|
id: enableLinkRoot
|
|
|
|
width: 300
|
|
|
|
height: childrenRect.height + Style.current.smallPadding
|
|
|
|
radius: 16
|
|
|
|
border.width: 1
|
|
|
|
border.color: Style.current.border
|
|
|
|
color: Style.current.background
|
|
|
|
StatusFlatRoundButton {
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
|
|
|
icon.width: 20
|
|
|
|
icon.height: 20
|
|
|
|
icon.name: "close-circle"
|
|
|
|
onClicked: linksModel.remove(index)
|
|
|
|
}
|
|
|
|
Image {
|
|
|
|
id: unfurlingImage
|
|
|
|
source: Style.png("unfurling-image")
|
|
|
|
width: 132
|
|
|
|
height: 94
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
id: enableText
|
|
|
|
text: isImage ? qsTr("Enable automatic image unfurling") :
|
|
|
|
qsTr("Enable link previews in chat?")
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
width: parent.width
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
anchors.top: unfurlingImage.bottom
|
|
|
|
anchors.topMargin: Style.current.halfPadding
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
id: infoText
|
|
|
|
text: qsTr("Once enabled, links posted in the chat may share your metadata with their owners")
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
width: parent.width
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
anchors.top: enableText.bottom
|
|
|
|
font.pixelSize: 13
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
Separator {
|
|
|
|
id: sep1
|
|
|
|
anchors.top: infoText.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
}
|
|
|
|
StatusFlatButton {
|
|
|
|
id: enableBtn
|
|
|
|
objectName: "LinksMessageView_enableBtn"
|
|
|
|
text: qsTr("Enable in Settings")
|
|
|
|
onClicked: {
|
|
|
|
Global.changeAppSectionBySectionType(Constants.appSection.profile, Constants.settingsSubsection.messaging);
|
|
|
|
}
|
|
|
|
width: parent.width
|
|
|
|
anchors.top: sep1.bottom
|
|
|
|
Component.onCompleted: {
|
|
|
|
background.radius = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Separator {
|
|
|
|
id: sep2
|
|
|
|
anchors.top: enableBtn.bottom
|
|
|
|
anchors.topMargin: 0
|
|
|
|
}
|
|
|
|
Item {
|
|
|
|
width: parent.width
|
|
|
|
height: 44
|
|
|
|
anchors.top: sep2.bottom
|
|
|
|
clip: true
|
|
|
|
StatusFlatButton {
|
|
|
|
id: dontAskBtn
|
|
|
|
width: parent.width
|
|
|
|
height: (parent.height+Style.current.padding)
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: -Style.current.padding
|
|
|
|
contentItem: Item {
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
anchors.verticalCenterOffset: Style.current.halfPadding
|
|
|
|
font: dontAskBtn.font
|
|
|
|
color: dontAskBtn.enabled ? dontAskBtn.textColor : dontAskBtn.disabledTextColor
|
|
|
|
text: qsTr("Don't ask me again")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onClicked: RootStore.setNeverAskAboutUnfurlingAgain(true)
|
|
|
|
Component.onCompleted: {
|
|
|
|
background.radius = Style.current.padding;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-23 19:46:44 +00:00
|
|
|
}
|