fix(Chat): improve gif confirmation popup and fix preview whitelisting
Enable preview for gifs after enabling the gif functionality Disable gif functionality if the preview was disabled Addition fixes - The gifs weren't checked if all images weren't enabled - The subdomain wasn't checked for whitelisting if the main domain wasn't enabled - Image clicking - Dismiss asking for unfurling was not updating the state Considerations - Looked into having the "gif enabled" - "tenor unfurling" relation embedded in the controller but it would require extensive refactoring by implementing a data-model for unfurling whitelisted domains Closes: #6829
This commit is contained in:
parent
b691d358e5
commit
d81b6ca518
|
@ -9,6 +9,7 @@ import shared.panels 1.0
|
|||
import shared.popups 1.0
|
||||
import shared.status 1.0
|
||||
import shared.controls 1.0
|
||||
import shared.stores 1.0
|
||||
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
|
@ -263,7 +264,7 @@ SettingsContentBase {
|
|||
previewableSites.clear()
|
||||
var oneEntryIsActive = false
|
||||
whitelist.forEach(entry => {
|
||||
entry.isWhitelisted = localAccountSensitiveSettings.whitelistedUnfurlingSites[entry.address] || false
|
||||
entry.isWhitelisted = !!localAccountSensitiveSettings.whitelistedUnfurlingSites[entry.address]
|
||||
if (entry.isWhitelisted) {
|
||||
oneEntryIsActive = true
|
||||
}
|
||||
|
@ -303,6 +304,11 @@ SettingsContentBase {
|
|||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: localAccountSensitiveSettings
|
||||
onWhitelistedUnfurlingSitesChanged: generalColumn.populatePreviewableSites()
|
||||
}
|
||||
|
||||
// Manually add switch for the image unfurling
|
||||
StatusListItem {
|
||||
objectName: "imageUnfurlingItem"
|
||||
|
@ -356,6 +362,7 @@ SettingsContentBase {
|
|||
case "medium":
|
||||
filename = "medium"; break;
|
||||
case "tenor gifs":
|
||||
case "tenor gifs subdomain":
|
||||
filename = "tenor"; break;
|
||||
case "giphy gifs":
|
||||
case "giphy gifs shortener":
|
||||
|
@ -375,20 +382,7 @@ SettingsContentBase {
|
|||
StatusSwitch {
|
||||
id: siteSwitch
|
||||
checked: !!model.isWhitelisted
|
||||
onCheckedChanged: {
|
||||
let settings = localAccountSensitiveSettings.whitelistedUnfurlingSites
|
||||
|
||||
if (!settings) {
|
||||
settings = {}
|
||||
}
|
||||
|
||||
if (settings[address] === this.checked) {
|
||||
return
|
||||
}
|
||||
|
||||
settings[address] = this.checked
|
||||
localAccountSensitiveSettings.whitelistedUnfurlingSites = settings
|
||||
}
|
||||
onCheckedChanged: RootStore.updateWhitelistedUnfurlingSites(model.address, checked)
|
||||
}
|
||||
]
|
||||
onClicked: {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick 2.14
|
||||
import QtQuick.Controls 2.14
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
import StatusQ.Core 0.1
|
||||
|
@ -80,6 +80,7 @@ Popup {
|
|||
|
||||
onClicked: {
|
||||
RootStore.setIsTenorWarningAccepted(true)
|
||||
RootStore.updateWhitelistedUnfurlingSites("media.tenor.com", true)
|
||||
RootStore.getTrendingsGifs()
|
||||
root.close()
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@ Rectangle {
|
|||
|
||||
signal doRetry()
|
||||
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
color: Style.current.background
|
||||
|
||||
StatusBaseText {
|
||||
|
|
|
@ -106,6 +106,22 @@ QtObject {
|
|||
chatSectionChatContentInputArea.getTrendingsGifs()
|
||||
}
|
||||
|
||||
function updateWhitelistedUnfurlingSites(hostname, whitelisted) {
|
||||
// no way to send update notification for individual array entries
|
||||
let settings = localAccountSensitiveSettings.whitelistedUnfurlingSites
|
||||
|
||||
if (!settings)
|
||||
settings = {}
|
||||
|
||||
if (settings[hostname] === whitelisted)
|
||||
return
|
||||
|
||||
settings[hostname] = whitelisted
|
||||
localAccountSensitiveSettings.whitelistedUnfurlingSites = settings
|
||||
if(hostname === "media.tenor.com" && whitelisted === false)
|
||||
RootStore.setIsTenorWarningAccepted(false)
|
||||
}
|
||||
|
||||
function getRecentsGifs() {
|
||||
chatSectionChatContentInputArea.getRecentsGifs()
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ Column {
|
|||
property string linkUrls: ""
|
||||
property bool isCurrentUser: false
|
||||
property bool isImageLink: false
|
||||
|
||||
signal imageClicked(var image)
|
||||
|
||||
spacing: Style.current.halfPadding
|
||||
height: childrenRect.height
|
||||
|
||||
|
@ -76,12 +79,12 @@ Column {
|
|||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
id: linkFetchConnections
|
||||
enabled: false
|
||||
target: root.messageStore.messageModule
|
||||
onLinkPreviewDataWasReceived: {
|
||||
let response
|
||||
Connections {
|
||||
id: linkFetchConnections
|
||||
enabled: false
|
||||
target: root.messageStore.messageModule
|
||||
onLinkPreviewDataWasReceived: {
|
||||
let response = {}
|
||||
try {
|
||||
response = JSON.parse(previewData)
|
||||
} catch (e) {
|
||||
|
@ -106,8 +109,8 @@ Column {
|
|||
linkData.address = link
|
||||
return linkMessageLoader.sourceComponent = unfurledLinkComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
id: linkCommunityFetchConnections
|
||||
|
@ -134,37 +137,26 @@ Column {
|
|||
// Reset the height in case we set it to 0 below. See note below
|
||||
// for more information
|
||||
this.height = undefined
|
||||
if (Utils.hasImageExtension(link)) {
|
||||
if (RootStore.displayChatImages) {
|
||||
linkData = {
|
||||
thumbnailUrl: link
|
||||
}
|
||||
return unfurledImageComponent
|
||||
} else {
|
||||
if (RootStore.neverAskAboutUnfurlingAgain || (isImageLink && index > 0)) {
|
||||
return
|
||||
}
|
||||
|
||||
isImageLink = true
|
||||
return enableLinkComponent
|
||||
}
|
||||
}
|
||||
|
||||
let linkWhiteListed = false
|
||||
const linkHostname = Utils.getHostname(link)
|
||||
if (!localAccountSensitiveSettings.whitelistedUnfurlingSites) {
|
||||
localAccountSensitiveSettings.whitelistedUnfurlingSites = {}
|
||||
}
|
||||
const linkExists = Object.keys(localAccountSensitiveSettings.whitelistedUnfurlingSites).some(function(whitelistedHostname) {
|
||||
const exists = linkHostname.endsWith(whitelistedHostname)
|
||||
if (exists) {
|
||||
linkWhiteListed = localAccountSensitiveSettings.whitelistedUnfurlingSites[whitelistedHostname] === true
|
||||
}
|
||||
return exists
|
||||
|
||||
const whitelistHosts = Object.keys(localAccountSensitiveSettings.whitelistedUnfurlingSites)
|
||||
const linkExists = whitelistHosts.some(function(hostname) {
|
||||
return linkHostname.endsWith(hostname)
|
||||
})
|
||||
if (!linkWhiteListed && linkExists && !RootStore.neverAskAboutUnfurlingAgain) {
|
||||
|
||||
const linkWhiteListed = linkExists && whitelistHosts.some(function(hostname) {
|
||||
return linkHostname.endsWith(hostname) && localAccountSensitiveSettings.whitelistedUnfurlingSites[hostname] === true
|
||||
})
|
||||
|
||||
const isImage = Utils.hasImageExtension(link)
|
||||
if (!linkWhiteListed && linkExists && !RootStore.neverAskAboutUnfurlingAgain && !isImage) {
|
||||
return enableLinkComponent
|
||||
}
|
||||
|
||||
if (linkWhiteListed) {
|
||||
if (fetched) {
|
||||
if (linkData.communityId) {
|
||||
|
@ -193,6 +185,20 @@ Column {
|
|||
|
||||
root.messageStore.getLinkPreviewData(link, linkMessageLoader.uuid)
|
||||
}
|
||||
|
||||
if (isImage) {
|
||||
if (RootStore.displayChatImages) {
|
||||
linkData = {
|
||||
thumbnailUrl: link
|
||||
}
|
||||
return unfurledImageComponent
|
||||
}
|
||||
else if (!(RootStore.neverAskAboutUnfurlingAgain || (isImageLink && index > 0))) {
|
||||
isImageLink = true
|
||||
return enableLinkComponent
|
||||
}
|
||||
}
|
||||
|
||||
// setting the height to 0 allows the "enable link" dialog to
|
||||
// disappear correctly when RootStore.neverAskAboutUnfurlingAgain
|
||||
// is true. The height is reset at the top of this method.
|
||||
|
|
|
@ -637,6 +637,9 @@ Loader {
|
|||
messageStore: root.messageStore
|
||||
store: root.rootStore
|
||||
isCurrentUser: root.amISender
|
||||
onImageClicked: {
|
||||
root.imageClicked(image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ed4a1c46f18cef446169b37ef2f34effb509e30c
|
||||
Subproject commit bc00836df2c8027381977cc24a473f97290b12b8
|
Loading…
Reference in New Issue