Files
paperclip-wallet/renderer/settings.js
Taegus 3fa90b2e48 + delete wallet data support
+ added fs-extra module
+ use copyFileSync
2019-01-29 15:13:58 +01:00

83 lines
3.4 KiB
JavaScript

// In renderer process (web page).
const {ipcRenderer} = require('electron');
class Settings {
constructor() {}
renderSettingsState() {
EthoMainGUI.renderTemplate("settings.html", {});
$(document).trigger("render_settings");
}
}
$(document).on("render_settings", function() {
$("#btnSettingsCleanTransactions").off('click').on('click', function() {
if (isFullySynced) {
EthoMainGUI.showGeneralConfirmation("Do you really want to resync transactions?", function(result) {
if (result) {
if (EthoTransactions.getIsSyncing()) {
EthoMainGUI.showGeneralError("Transactions sync is currently in progress");
} else {
// first disable keepInSync
EthoTransactions.disableKeepInSync();
// then delete the transactions data
var counters = EthoDatatabse.getCounters();
counters.transactions = 0;
EthoDatatabse.setCounters(counters);
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);
}
}
}
});
} else {
iziToast.info({
title: 'Wait...',
message: 'You need to be fully sync before cleaning transactions',
position: 'topRight',
timeout: 5000
});
}
});
$("#btnSettingsCleanWallets").off('click').on('click', function() {
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() {
EthoMainGUI.showGeneralError("Not implemented yet!");
});
});
// create new account variable
EthoSettings = new Settings();