From 5d0eb942b0b8021b2c308c17cdcbe2a4b3e10d50 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Fri, 4 Feb 2022 15:49:16 -0500 Subject: [PATCH] fix(PrivacyView): [re-add] Fix relations between switch and line sensor Fixes #4674 The part about profile image was already refactpred/fixed --- .../Profile/stores/PrivacyStore.qml | 1 - .../AppLayouts/Profile/views/PrivacyView.qml | 29 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml b/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml index d1229f257a..84146997d1 100644 --- a/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml +++ b/ui/app/AppLayouts/Profile/stores/PrivacyStore.qml @@ -8,7 +8,6 @@ QtObject { // Module Properties property bool mnemonicBackedUp: privacyModule.mnemonicBackedUp - property bool messagesFromContactsOnly: privacyModule.messagesFromContactsOnly function getLinkPreviewWhitelist() { return root.privacyModule.getLinkPreviewWhitelist() diff --git a/ui/app/AppLayouts/Profile/views/PrivacyView.qml b/ui/app/AppLayouts/Profile/views/PrivacyView.qml index 944f183812..f7b6bf0d6d 100644 --- a/ui/app/AppLayouts/Profile/views/PrivacyView.qml +++ b/ui/app/AppLayouts/Profile/views/PrivacyView.qml @@ -157,11 +157,16 @@ Item { StatusQControls.StatusSwitch { id: switch1 checked: !localAccountSensitiveSettings.onlyShowContactsProfilePics - onClicked: { - localAccountSensitiveSettings.onlyShowContactsProfilePics = !checked + onCheckedChanged: { + if (localAccountSensitiveSettings.onlyShowContactsProfilePics === checked) { + localAccountSensitiveSettings.onlyShowContactsProfilePics = !checked + } } } ] + sensor.onClicked: { + switch1.checked = !switch1.checked + } } StatusListItem { @@ -176,11 +181,16 @@ Item { StatusQControls.StatusSwitch { id: switch2 checked: localAccountSensitiveSettings.displayChatImages - onClicked: { - localAccountSensitiveSettings.displayChatImages = checked + onCheckedChanged: { + if (localAccountSensitiveSettings.displayChatImages !== checked) { + localAccountSensitiveSettings.displayChatImages = checked + } } } ] + sensor.onClicked: { + switch2.checked = !switch2.checked + } } StatusBaseText { @@ -255,11 +265,18 @@ Item { components: [ StatusQControls.StatusSwitch { id: switch3 - checked: !root.privacyStore.messagesFromContactsOnly + checked: !root.privacyStore.privacyModule.messagesFromContactsOnly + onCheckedChanged: { + // messagesFromContactsOnly needs to be accessed from the module (view), + // because otherwise doing `messagesFromContactsOnly = value` only changes the bool property on QML + if (root.privacyStore.privacyModule.messagesFromContactsOnly === checked) { + root.privacyStore.privacyModule.messagesFromContactsOnly = !checked + } + } } ] sensor.onClicked: { - switch3.checked = root.privacyStore.messagesFromContactsOnly = !switch3.checked + switch3.checked = !switch3.checked } } }