WalletManager: async close with splash screen

This commit is contained in:
xiphon 2019-07-02 10:57:37 +00:00
parent c4b3fbae1d
commit ab9e31e7cc
4 changed files with 34 additions and 30 deletions

View file

@ -283,7 +283,7 @@ ApplicationWindow {
titleBar.visible = persistentSettings.customDecorations; titleBar.visible = persistentSettings.customDecorations;
} }
function closeWallet() { function closeWallet(callback) {
// Disconnect all listeners // Disconnect all listeners
if (typeof currentWallet !== "undefined" && currentWallet !== null) { if (typeof currentWallet !== "undefined" && currentWallet !== null) {
@ -306,8 +306,17 @@ ApplicationWindow {
} }
currentWallet = undefined; currentWallet = undefined;
walletManager.closeWallet();
appWindow.showProcessingSplash(qsTr("Closing wallet..."));
if (callback) {
walletManager.closeWalletAsync(function() {
hideProcessingSplash();
callback();
});
} else {
walletManager.closeWallet();
hideProcessingSplash();
}
} }
function connectWallet(wallet) { function connectWallet(wallet) {
@ -558,11 +567,6 @@ ApplicationWindow {
} }
} }
function onWalletClosed(walletAddress) {
hideProcessingSplash();
console.log(">>> wallet closed: " + walletAddress)
}
function onWalletPassphraseNeeded(){ function onWalletPassphraseNeeded(){
if(rootItem.state !== "normal") return; if(rootItem.state !== "normal") return;
@ -1115,17 +1119,18 @@ ApplicationWindow {
function showWizard(){ function showWizard(){
clearMoneroCardLabelText(); clearMoneroCardLabelText();
walletInitialized = false; walletInitialized = false;
closeWallet(); closeWallet(function() {
currentWallet = undefined; currentWallet = undefined;
wizard.restart(); wizard.restart();
wizard.wizardState = "wizardHome"; wizard.wizardState = "wizardHome";
rootItem.state = "wizard" rootItem.state = "wizard"
// reset balance // reset balance
leftPanel.balanceText = leftPanel.unlockedBalanceText = walletManager.displayAmount(0); leftPanel.balanceText = leftPanel.unlockedBalanceText = walletManager.displayAmount(0);
fiatApiUpdateBalance(0, 0); fiatApiUpdateBalance(0, 0);
// disable timers // disable timers
userInActivityTimer.running = false; userInActivityTimer.running = false;
simpleModeConnectionTimer.running = false; simpleModeConnectionTimer.running = false;
});
} }
function hideMenu() { function hideMenu() {
@ -1289,7 +1294,6 @@ ApplicationWindow {
y = (Screen.height - maxWindowHeight) / 2 y = (Screen.height - maxWindowHeight) / 2
// //
walletManager.walletOpened.connect(onWalletOpened); walletManager.walletOpened.connect(onWalletOpened);
walletManager.walletClosed.connect(onWalletClosed);
walletManager.deviceButtonRequest.connect(onDeviceButtonRequest); walletManager.deviceButtonRequest.connect(onDeviceButtonRequest);
walletManager.deviceButtonPressed.connect(onDeviceButtonPressed); walletManager.deviceButtonPressed.connect(onDeviceButtonPressed);
walletManager.checkUpdatesComplete.connect(onWalletCheckUpdatesComplete); walletManager.checkUpdatesComplete.connect(onWalletCheckUpdatesComplete);
@ -2131,8 +2135,8 @@ ApplicationWindow {
console.log("close accepted"); console.log("close accepted");
// Close wallet non async on exit // Close wallet non async on exit
daemonManager.exit(); daemonManager.exit();
walletManager.closeWallet();
Qt.quit(); closeWallet(Qt.quit);
} }
function onWalletCheckUpdatesComplete(update) { function onWalletCheckUpdatesComplete(update) {

View file

@ -208,10 +208,11 @@ Rectangle {
confirmationDialog.icon = StandardIcon.Question confirmationDialog.icon = StandardIcon.Question
confirmationDialog.cancelText = qsTr("Cancel") confirmationDialog.cancelText = qsTr("Cancel")
confirmationDialog.onAcceptedCallback = function() { confirmationDialog.onAcceptedCallback = function() {
walletManager.closeWallet(); appWindow.closeWallet(function() {
walletManager.clearWalletCache(persistentSettings.wallet_path); walletManager.clearWalletCache(persistentSettings.wallet_path);
walletManager.openWalletAsync(persistentSettings.wallet_path, appWindow.walletPassword, walletManager.openWalletAsync(persistentSettings.wallet_path, appWindow.walletPassword,
persistentSettings.nettype, persistentSettings.kdfRounds); persistentSettings.nettype, persistentSettings.kdfRounds);
});
} }
confirmationDialog.onRejectedCallback = null; confirmationDialog.onRejectedCallback = null;

View file

@ -228,11 +228,11 @@ QString WalletManager::closeWallet()
return result; return result;
} }
void WalletManager::closeWalletAsync() void WalletManager::closeWalletAsync(const QJSValue& callback)
{ {
m_scheduler.run([this] { m_scheduler.run([this] {
emit walletClosed(closeWallet()); return QJSValueList({closeWallet()});
}); }, callback);
} }
bool WalletManager::walletExists(const QString &path) const bool WalletManager::walletExists(const QString &path) const

View file

@ -117,7 +117,7 @@ public:
/*! /*!
* \brief closeWalletAsync - asynchronous version of "closeWallet" * \brief closeWalletAsync - asynchronous version of "closeWallet"
*/ */
Q_INVOKABLE void closeWalletAsync(); Q_INVOKABLE void closeWalletAsync(const QJSValue& callback);
//! checks is given filename is a wallet; //! checks is given filename is a wallet;
Q_INVOKABLE bool walletExists(const QString &path) const; Q_INVOKABLE bool walletExists(const QString &path) const;
@ -192,7 +192,6 @@ signals:
void walletPassphraseNeeded(); void walletPassphraseNeeded();
void deviceButtonRequest(quint64 buttonCode); void deviceButtonRequest(quint64 buttonCode);
void deviceButtonPressed(); void deviceButtonPressed();
void walletClosed(const QString &walletAddress);
void checkUpdatesComplete(const QString &result) const; void checkUpdatesComplete(const QString &result) const;
void miningStatus(bool isMining) const; void miningStatus(bool isMining) const;