diff --git a/assets/templates/settings.html b/assets/templates/settings.html
index 654ac33..083c7ec 100644
--- a/assets/templates/settings.html
+++ b/assets/templates/settings.html
@@ -6,7 +6,7 @@
- Clean wallets data
+ Clean wallet names
diff --git a/modules/accounts.js b/modules/accounts.js
index 71948ab..e2b4d13 100644
--- a/modules/accounts.js
+++ b/modules/accounts.js
@@ -1,7 +1,7 @@
const {app, dialog, ipcMain} = require('electron');
const admZip = require('adm-zip');
const path = require('path');
-const fs = require('fs');
+const fs = require('fs-extra');
const os = require('os');
class Accounts {
@@ -47,13 +47,12 @@ class Accounts {
zip.extractAllTo(accPath, true);
return { success: true, text: "Accounts ware successfully imported."};
} else {
- fs.copyFile(accountsFile, path.join(accPath, path.basename(accountsFile)), (err) => {
- if (err) {
- return { success: false, text: err};
- } else {
- return { success: true, text: "Account was successfully imported."};
- }
- });
+ try {
+ fs.copySync(accountsFile, path.join(accPath, path.basename(accountsFile)));
+ return { success: true, text: "Account was successfully imported."};
+ } catch (err) {
+ return { success: false, text: err};
+ }
}
}
diff --git a/modules/database.js b/modules/database.js
index 95fa001..925b405 100644
--- a/modules/database.js
+++ b/modules/database.js
@@ -83,7 +83,16 @@ ipcMain.on('deleteTransactions', (event, arg) => {
fs.unlink(dbPath, (err) => {
if (err) {
event.returnValue = { success: false, error: err };
- dialog.showErrorBox("Error deleting the file", err.message);
+ } else {
+ event.returnValue = { success: true, error: null };
+ }
+ });
+});
+
+ipcMain.on('deleteWalletData', (event, arg) => {
+ fs.unlink(path.join(app.getPath('userData'), 'wallets.json'), (err) => {
+ if (err) {
+ event.returnValue = { success: false, error: err };
} else {
event.returnValue = { success: true, error: null };
}
diff --git a/package.json b/package.json
index 7342cc7..3e43144 100644
--- a/package.json
+++ b/package.json
@@ -55,6 +55,7 @@
"adm-zip": "^0.4.13",
"app-root-path": "^2.1.0",
"electron-storage": "^1.0.7",
+ "fs-extra": "^7.0.1",
"handlebars": "^4.0.12",
"moment": "^2.23.0",
"nedb": "^1.8.0",
diff --git a/renderer/settings.js b/renderer/settings.js
index 1309b2e..25ba34c 100644
--- a/renderer/settings.js
+++ b/renderer/settings.js
@@ -24,23 +24,28 @@ $(document).on("render_settings", function() {
var counters = EthoDatatabse.getCounters();
counters.transactions = 0;
EthoDatatabse.setCounters(counters);
- ipcRenderer.sendSync('deleteTransactions', null);
- // sync all the transactions to the current block
- web3Local.eth.getBlock("latest", function(error, localBlock) {
- if (error) {
- EthoMainGUI.showGeneralError(error);
- } else {
- EthoTransactions.enableKeepInSync();
- EthoTransactions.syncTransactionsForAllAddresses(localBlock.number);
-
- iziToast.success({
- title: 'Success',
- message: 'Transactions are being resynced',
- position: 'topRight',
- timeout: 5000
- });
- }
- });
+ ipcResult = ipcRenderer.sendSync('deleteTransactions', null);
+
+ if (ipcResult.success) {
+ // sync all the transactions to the current block
+ web3Local.eth.getBlock("latest", function(error, localBlock) {
+ if (error) {
+ EthoMainGUI.showGeneralError(error);
+ } else {
+ EthoTransactions.enableKeepInSync();
+ EthoTransactions.syncTransactionsForAllAddresses(localBlock.number);
+
+ iziToast.success({
+ title: 'Success',
+ message: 'Transactions are being resynced',
+ position: 'topRight',
+ timeout: 5000
+ });
+ }
+ });
+ } else {
+ EthoMainGUI.showGeneralError("Error resyncing transactions: " + ipcResult.error);
+ }
}
}
});
@@ -55,7 +60,18 @@ $(document).on("render_settings", function() {
});
$("#btnSettingsCleanWallets").off('click').on('click', function() {
- EthoMainGUI.showGeneralError("Not implemented yet!");
+ ipcResult = ipcRenderer.sendSync('deleteWalletData', null);
+
+ if (ipcResult.success) {
+ iziToast.success({
+ title: 'Success',
+ message: 'Wallet names were succesfully cleaned',
+ position: 'topRight',
+ timeout: 5000
+ });
+ } else {
+ EthoMainGUI.showGeneralError("Error clearing wallet names: " + ipcResult.error);
+ }
});
$("#btnSettingsCleanBlockchain").off('click').on('click', function() {