open last opened wallet on gui start.

This commit is contained in:
Jacob Brydolf 2016-10-30 17:58:12 +01:00
parent 1218bf322c
commit e09ccd3c9a
No known key found for this signature in database
GPG key ID: DE46246550D2F3C5

View file

@ -316,12 +316,19 @@ ApplicationWindow {
function walletsFound() { function walletsFound() {
if (persistentSettings.wallet_path.length > 0) {
var lastOpenedExists = walletManager.walletExists(persistentSettings.wallet_path);
if (lastOpenedExists) {
console.log("Last opened wallet exists in:",persistentSettings.wallet_path)
}
}
// Check if wallets exists in default path
var wallets = walletManager.findWallets(moneroAccountsDir); var wallets = walletManager.findWallets(moneroAccountsDir);
if (wallets.length === 0) { if (wallets.length === 0) {
wallets = walletManager.findWallets(applicationDirectory); wallets = walletManager.findWallets(applicationDirectory);
} }
console.log("wallets found: ",wallets); return (wallets.length > 0 || lastOpenedExists);
return wallets.length;
} }
@ -438,6 +445,7 @@ ApplicationWindow {
function showWizard(){ function showWizard(){
walletInitialized = false; walletInitialized = false;
splashCounter = 0; splashCounter = 0;
// we can't close async here. Gui crashes if wallet is open
walletManager.closeWallet(currentWallet); walletManager.closeWallet(currentWallet);
wizard.restart(); wizard.restart();
rootItem.state = "wizard" rootItem.state = "wizard"
@ -460,20 +468,12 @@ ApplicationWindow {
// //
walletManager.walletOpened.connect(onWalletOpened); walletManager.walletOpened.connect(onWalletOpened);
walletManager.walletClosed.connect(onWalletClosed); walletManager.walletClosed.connect(onWalletClosed);
var numWalletsFound = walletsFound();
if(!numWalletsFound) { if(!walletsFound()) {
rootItem.state = "wizard" rootItem.state = "wizard"
} else { } else {
rootItem.state = "normal" rootItem.state = "normal"
// If more than 1 wallet found, open file dialog.
// TODO: implement prettier wallet picker
if(numWalletsFound > 1) {
openWalletFromFile();
} else {
initialize(persistentSettings); initialize(persistentSettings);
}
} }
} }
@ -530,9 +530,9 @@ ApplicationWindow {
id: fileDialog id: fileDialog
title: "Please choose a file" title: "Please choose a file"
folder: "file://" +moneroAccountsDir folder: "file://" +moneroAccountsDir
nameFilters: [ "Wallet files (*.keys)"]
onAccepted: { onAccepted: {
console.log("You chose: " + walletManager.urlToLocalPath(fileDialog.fileUrl))
persistentSettings.wallet_path = walletManager.urlToLocalPath(fileDialog.fileUrl) persistentSettings.wallet_path = walletManager.urlToLocalPath(fileDialog.fileUrl)
initialize(); initialize();
} }
@ -865,7 +865,6 @@ ApplicationWindow {
} }
} }
onClosing: { onClosing: {
walletManager.closeWallet(currentWallet); //walletManager.closeWallet(currentWallet);
console.log("onClosing called");
} }
} }