feat(settings) add notification to biometrics enable

Closes #13896
This commit is contained in:
Stefan 2024-03-15 14:13:35 +02:00 committed by Stefan Dunca
parent db6e24e4c3
commit 1b77695e01
2 changed files with 26 additions and 11 deletions

View File

@ -42,6 +42,7 @@ SplitView {
if (generateMacKeyChainStoreError.checked) {
privacyModule.storeToKeychainError(errorDescription)
} else {
passwordView.localAccountSettings.storeToKeychainValue = Constants.keychain.storedValue.store
privacyModule.storeToKeychainSuccess()
privacyModule.passwordChanged(true, "")
}
@ -49,8 +50,9 @@ SplitView {
function tryRemoveFromKeyChain() {
if (generateMacKeyChainStoreError.checked) {
privacyModule.storeToKeychainError(errorDescription)
privacyModule.storeToKeychainError("Error removing from keychain")
} else {
passwordView.localAccountSettings.storeToKeychainValue = Constants.keychain.storedValue.notNow
privacyModule.storeToKeychainSuccess()
}
}

View File

@ -25,20 +25,30 @@ SettingsContentBase {
readonly property bool biometricsEnabled: localAccountSettings.storeToKeychainValue === Constants.keychain.storedValue.store
readonly property StatusSwitch biometricsSwitch: titleRowComponentLoader.item.switchItem
readonly property Item biometricsPopup: titleRowComponentLoader.item
readonly property Connections privacyStoreConnections: Connections {
target: Qt.platform.os === Constants.mac ? root.privacyStore.privacyModule : null
function onStoreToKeychainError(errorDescription: string) {
root.biometricsSwitch.checked = Qt.binding(() => {
return root.biometricsSwitch.currentStoredValue
})
biometricsPopup.popupItem.close();
if (biometricsPopup.switchItem.requestForEnabling) {
Global.displayToastMessage(qsTr("Failed to enable biometric login and transaction authentication for this device"),
errorDescription, "warning", false, Constants.ephemeralNotificationType.danger, "")
} else {
Global.displayToastMessage(qsTr("Failed to disable biometric login and transaction authentication for this device"),
errorDescription, "warning", false, Constants.ephemeralNotificationType.danger, "")
}
}
function onStoreToKeychainSuccess() {
root.biometricsSwitch.checked = Qt.binding(() => {
return root.biometricsSwitch.currentStoredValue
})
biometricsPopup.popupItem.close();
if (biometricsPopup.switchItem.requestForEnabling) {
Global.displayToastMessage(qsTr("Biometric login and transaction authentication enabled for this device"),
"", "checkmark-circle", false, Constants.ephemeralNotificationType.success, "")
} else {
Global.displayToastMessage(qsTr("Biometric login and transaction authentication disabled for this device"),
"", "checkmark-circle", false, Constants.ephemeralNotificationType.success, "")
}
}
}
@ -50,6 +60,8 @@ SettingsContentBase {
visible: (Qt.platform.os === Constants.mac)
property StatusSwitch switchItem: biometricsSwitch
property StatusDialog popupItem: enableBiometricsPopup
StatusSwitch {
id: biometricsSwitch
@ -59,11 +71,10 @@ SettingsContentBase {
text: qsTr("Enable biometrics")
textColor: Theme.palette.baseColor1
property bool currentStoredValue: false
property bool requestForEnabling: false
checked: root.biometricsEnabled
onToggled: {
currentStoredValue = checked
onReleased: {
enableBiometricsPopup.open();
}
StatusToolTip {
@ -98,8 +109,10 @@ SettingsContentBase {
text: biometricsSwitch.checked ? qsTr("Yes, enable biometrics") : qsTr("Yes, disable biometrics")
onClicked: {
if (biometricsSwitch.checked && !biometricsSwitch.biometricsEnabled) {
biometricsSwitch.requestForEnabling = true;
root.privacyStore.tryStoreToKeyChain();
} else if (!biometricsSwitch.checked) {
biometricsSwitch.requestForEnabling = false;
root.privacyStore.tryRemoveFromKeyChain();
}
}