Cancel device delete when popup closed

This commit is contained in:
miruka 2020-06-29 10:46:37 -04:00
parent d701e5ea77
commit 196d57701a

View File

@ -3,6 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import "../Base" import "../Base"
import "../Base/ButtonLayout" import "../Base/ButtonLayout"
import "../PythonBridge"
PasswordPopup { PasswordPopup {
id: popup id: popup
@ -12,13 +13,18 @@ PasswordPopup {
property var deviceIds // array property var deviceIds // array
property var deletedCallback: null property var deletedCallback: null
property Future deleteFuture: null
function verifyPassword(pass, callback) { function verifyPassword(pass, callback) {
py.callClientCoro( deleteFuture = py.callClientCoro(
userId, userId,
"delete_devices_with_password", "delete_devices_with_password",
[deviceIds, pass], [deviceIds, pass],
() => callback(true), () => {
deleteFuture = null
callback(true)
},
(type, args) => { (type, args) => {
callback( callback(
type === "MatrixUnauthorized" ? type === "MatrixUnauthorized" ?
@ -36,5 +42,10 @@ PasswordPopup {
validateButton.text: qsTr("Sign out") validateButton.text: qsTr("Sign out")
validateButton.icon.name: "sign-out" validateButton.icon.name: "sign-out"
onClosed: if (acceptedPassword && deletedCallback) deletedCallback() onClosed: {
if (deleteFuture) deleteFuture.cancel()
if (deleteFuture || acceptedPassword && deletedCallback)
deletedCallback()
}
} }