Wizard: set unused wallet name

This commit is contained in:
selsta 2021-06-09 01:00:16 +02:00
parent 2946127ed7
commit f75a2447a7
No known key found for this signature in database
GPG key ID: 2EA0A99A8B07AE5E
2 changed files with 12 additions and 1 deletions

View file

@ -82,6 +82,17 @@ function walletPathExists(accountsDir, directory, filename, isIOS, walletManager
return false;
}
function unusedWalletName(directory, filename, walletManager) {
for (var i = 0; i < 100; i++) {
var walletName = filename + (i > 0 ? "_" + i : "");
if (!walletManager.walletExists(directory + "/" + walletName + "/" + walletName)) {
return walletName;
}
}
return filename;
}
function isAscii(str){
for (var i = 0; i < str.length; i++) {
if (str.charCodeAt(i) > 127)

View file

@ -56,7 +56,7 @@ GridLayout {
walletName.error = !walletName.verify();
walletLocation.error = walletLocation.text === "";
walletLocation.text = appWindow.accountsDir;
walletName.text = defaultAccountName;
walletName.text = Wizard.unusedWalletName(appWindow.accountsDir, defaultAccountName, walletManager);
}
MoneroComponents.LineEdit {