Cancel device delete when popup closed
This commit is contained in:
parent
d701e5ea77
commit
196d57701a
|
@ -3,6 +3,7 @@
|
|||
import QtQuick 2.12
|
||||
import "../Base"
|
||||
import "../Base/ButtonLayout"
|
||||
import "../PythonBridge"
|
||||
|
||||
PasswordPopup {
|
||||
id: popup
|
||||
|
@ -12,13 +13,18 @@ PasswordPopup {
|
|||
property var deviceIds // array
|
||||
property var deletedCallback: null
|
||||
|
||||
property Future deleteFuture: null
|
||||
|
||||
|
||||
function verifyPassword(pass, callback) {
|
||||
py.callClientCoro(
|
||||
deleteFuture = py.callClientCoro(
|
||||
userId,
|
||||
"delete_devices_with_password",
|
||||
[deviceIds, pass],
|
||||
() => callback(true),
|
||||
() => {
|
||||
deleteFuture = null
|
||||
callback(true)
|
||||
},
|
||||
(type, args) => {
|
||||
callback(
|
||||
type === "MatrixUnauthorized" ?
|
||||
|
@ -36,5 +42,10 @@ PasswordPopup {
|
|||
validateButton.text: qsTr("Sign out")
|
||||
validateButton.icon.name: "sign-out"
|
||||
|
||||
onClosed: if (acceptedPassword && deletedCallback) deletedCallback()
|
||||
onClosed: {
|
||||
if (deleteFuture) deleteFuture.cancel()
|
||||
|
||||
if (deleteFuture || acceptedPassword && deletedCallback)
|
||||
deletedCallback()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user