diff --git a/package.json b/package.json index adb0c99..9c6e339 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Ether1Wallet", - "version": "0.1.3", + "version": "0.2.1", "description": "Desktop wallet for Ether1 currency", "main": "main.js", "scripts": { diff --git a/renderer/blockchain.js b/renderer/blockchain.js index 4f27211..94a1b0c 100644 --- a/renderer/blockchain.js +++ b/renderer/blockchain.js @@ -230,13 +230,15 @@ class Blockchain { } unsubsribePendingTransactions(clbError, clbSuccess) { - this.txSubscribe.unsubscribe(function(error, success){ - if(error) { - clbError(error); - } else { - clbSuccess(success) ; - } - }); + if (this.txSubscribe) { + this.txSubscribe.unsubscribe(function(error, success){ + if(error) { + clbError(error); + } else { + clbSuccess(success) ; + } + }); + } } subsribeNewBlockHeaders(clbError, clbSuccess, clbData) { @@ -254,13 +256,15 @@ class Blockchain { } unsubsribeNewBlockHeaders(clbError, clbSuccess) { - this.bhSubscribe.unsubscribe(function(error, success){ - if(error) { - clbError(error); - } else { - clbSuccess(success) ; - } - }); + if (this.bhSubscribe) { + this.bhSubscribe.unsubscribe(function(error, success){ + if(error) { + clbError(error); + } else { + clbSuccess(success) ; + } + }); + } } closeConnection() { diff --git a/renderer/settings.js b/renderer/settings.js index 78c2e68..1309b2e 100644 --- a/renderer/settings.js +++ b/renderer/settings.js @@ -12,37 +12,46 @@ class Settings { $(document).on("render_settings", function() { $("#btnSettingsCleanTransactions").off('click').on('click', function() { - 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); - 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 - }); - } - }); + 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); + 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 + }); + } + }); + } } - } - }); + }); + } 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() { diff --git a/renderer/syncing.js b/renderer/syncing.js index 252f062..3902a70 100644 --- a/renderer/syncing.js +++ b/renderer/syncing.js @@ -29,6 +29,7 @@ SyncProgress = new ProgressBar.Line('#syncProgress', // set initial value for the progress text SyncProgress.setText("Waiting for blockchain, please wait..."); +isFullySynced = false; var peerCountInterval = setInterval(function() { @@ -62,6 +63,7 @@ function StartSyncProcess() { // clear the repeat interval and render wallets $(document).trigger("onNewAccountTransaction"); alreadyCatchedUp = true; + isFullySynced = true; // enable the keep in sync feature EthoTransactions.enableKeepInSync(); diff --git a/renderer/transactions.js b/renderer/transactions.js index 14eddc4..93a51f8 100644 --- a/renderer/transactions.js +++ b/renderer/transactions.js @@ -27,7 +27,7 @@ class Transactions { } syncTransactionsForSingleAddress(addressList, counters, lastBlock, counter) { - if (counter < addressList.length - 1) { + if (counter < addressList.length) { SyncProgress.setText(vsprintf("Syncing address transactions %d/%d, please wait...", [counter, addressList.length])); var startBlock = parseInt(counters.transactions) || 0;