Fix showMessageLinksSwitch bindings

Property bindings were added for showMessageLinksSwitch in order for it to change the checked state whenever previewableSites model has any item checked or displayChatImages setting is true.
This commit is contained in:
Alex Jbanca 2022-11-07 17:21:03 +02:00
parent 0d3f872c5c
commit 0996ef3612
1 changed files with 9 additions and 9 deletions

View File

@ -144,8 +144,8 @@ SettingsContentBase {
RootStore.updateWhitelistedUnfurlingSites(item.address, false) RootStore.updateWhitelistedUnfurlingSites(item.address, false)
} }
} }
checked: false checked: previewableSites.anyWhitelisted || localAccountSensitiveSettings.displayChatImages
onCheckedChanged: { onToggled: {
if (checked === false) { if (checked === false) {
switchOffPreviewableSites() switchOffPreviewableSites()
} }
@ -153,7 +153,10 @@ SettingsContentBase {
} }
] ]
onClicked: { onClicked: {
showMessageLinksSwitch.checked = !showMessageLinksSwitch.checked showMessageLinksSwitch.toggle()
if (showMessageLinksSwitch.checked === false) {
showMessageLinksSwitch.switchOffPreviewableSites()
}
} }
} }
@ -177,8 +180,8 @@ SettingsContentBase {
function populatePreviewableSites() { function populatePreviewableSites() {
const [anyWhitelisted, whitelist] = buildPreviewablesSitesJSON() const [anyWhitelisted, whitelist] = buildPreviewablesSitesJSON()
showMessageLinksSwitch.checked = anyWhitelisted
previewableSites.populateModel(whitelist) previewableSites.populateModel(whitelist)
previewableSites.anyWhitelisted = anyWhitelisted
} }
Component.onCompleted: { Component.onCompleted: {
@ -219,6 +222,8 @@ SettingsContentBase {
previewableSites.remove(jsonModel.length - 1, rowsToDelete) previewableSites.remove(jsonModel.length - 1, rowsToDelete)
} }
} }
property bool anyWhitelisted: false
} }
Connections { Connections {
@ -243,11 +248,6 @@ SettingsContentBase {
// TODO find a better icon for this // TODO find a better icon for this
asset.name: Style.svg('globe') asset.name: Style.svg('globe')
asset.isImage: true asset.isImage: true
Component.onCompleted: {
if (localAccountSensitiveSettings.displayChatImages) {
showMessageLinksSwitch.checked = true
}
}
components: [ components: [
StatusSwitch { StatusSwitch {
id: imageSwitch id: imageSwitch