From 196d57701a268d4f631213238162aa7acad455e3 Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 29 Jun 2020 10:46:37 -0400 Subject: [PATCH] Cancel device delete when popup closed --- src/gui/Popups/DeleteDevicesPopup.qml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gui/Popups/DeleteDevicesPopup.qml b/src/gui/Popups/DeleteDevicesPopup.qml index ae2422a6..1ddf4c13 100644 --- a/src/gui/Popups/DeleteDevicesPopup.qml +++ b/src/gui/Popups/DeleteDevicesPopup.qml @@ -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() + } }