Really cancel key import when clicking "Cancel"

This commit is contained in:
miruka 2020-03-21 12:43:16 -04:00
parent cb020ad479
commit 6662628b4e
2 changed files with 22 additions and 5 deletions

View File

@ -3,6 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import Qt.labs.platform 1.1 import Qt.labs.platform 1.1
import "../Popups" import "../Popups"
import "../PythonBridge"
HFileDialogOpener { HFileDialogOpener {
fill: false fill: false
@ -15,27 +16,37 @@ HFileDialogOpener {
property string userId: "" property string userId: ""
property bool importing: false property bool importing: false
property Future importFuture: null
PasswordPopup { PasswordPopup {
id: importPasswordPopup id: importPasswordPopup
details.text: qsTr("Passphrase used to protect this file:") details.text:
importing ?
qsTr("This might take a while...") :
qsTr("Passphrase used to protect this file:")
okText: qsTr("Import") okText: qsTr("Import")
onCancelled: if (importFuture) importFuture.cancel()
property url file: "" property url file: ""
function verifyPassword(pass, callback) { function verifyPassword(pass, callback) {
importing = true importing = true
const call = py.callClientCoro
const path = file.toString().replace(/^file:\/\//, "") const path = file.toString().replace(/^file:\/\//, "")
py.callClientCoro(userId, "import_keys", [path, pass], () => { importFuture = call(userId, "import_keys", [path, pass], () => {
importing = false importing = false
importFuture = null
callback(true) callback(true)
}, (type, args, error, traceback, uuid) => { }, (type, args, error, traceback, uuid) => {
let unknown = false let unknown = false
importFuture = null
callback( callback(
type === "EncryptionError" ? type === "EncryptionError" ?

View File

@ -17,6 +17,9 @@ BoxPopup {
onOpened: passwordField.forceActiveFocus() onOpened: passwordField.forceActiveFocus()
signal cancelled()
property bool validateWhileTyping: false property bool validateWhileTyping: false
property string acceptedPassword: "" property string acceptedPassword: ""
@ -54,7 +57,10 @@ BoxPopup {
button.loading = false button.loading = false
}) })
}, },
cancel: button => { popup.close() }, cancel: button => {
popup.close()
cancelled()
},
}) })