From 8187d9b24fbbcb27ebbef9469a1b6cc3508972c3 Mon Sep 17 00:00:00 2001 From: petitPapillon Date: Sat, 10 Jun 2017 10:48:05 +0200 Subject: [PATCH 1/3] Toaster component - remove the display property --- react/src/actions/actionCreators.js | 5 ++-- react/src/actions/actions/addCoin.js | 12 ++++---- react/src/actions/actions/addressBalance.js | 14 +++++----- react/src/actions/actions/atomic.js | 2 +- react/src/actions/actions/basiliskCache.js | 14 +++++----- .../actions/actions/basiliskProcessAddress.js | 16 +++++------ .../src/actions/actions/basiliskTxHistory.js | 2 +- react/src/actions/actions/cli.js | 4 +-- react/src/actions/actions/coinList.js | 4 +-- react/src/actions/actions/copyAddress.js | 4 +-- react/src/actions/actions/createWallet.js | 6 ++-- react/src/actions/actions/dexCoins.js | 2 +- react/src/actions/actions/edexBalance.js | 4 +-- react/src/actions/actions/edexGetTx.js | 2 +- react/src/actions/actions/fullTxHistory.js | 2 +- react/src/actions/actions/getAddrByAccount.js | 2 +- react/src/actions/actions/iguanaHelpers.js | 2 +- react/src/actions/actions/iguanaInstance.js | 6 ++-- react/src/actions/actions/log.js | 4 +-- react/src/actions/actions/logout.js | 2 +- react/src/actions/actions/nativeBalance.js | 2 +- react/src/actions/actions/nativeNewAddress.js | 4 +-- react/src/actions/actions/nativeSend.js | 8 +++--- react/src/actions/actions/nativeSyncInfo.js | 4 +-- react/src/actions/actions/nativeTxHistory.js | 2 +- react/src/actions/actions/notary.js | 8 +++--- react/src/actions/actions/openAlias.js | 2 +- react/src/actions/actions/sendFullBasilisk.js | 12 ++++---- react/src/actions/actions/settings.js | 28 +++++++++---------- react/src/actions/actions/syncInfo.js | 2 +- react/src/actions/actions/syncOnly.js | 6 ++-- react/src/actions/actions/sysInfo.js | 2 +- react/src/actions/actions/walletAuth.js | 10 +++---- react/src/components/addcoin/addcoin.js | 2 +- react/src/components/dashboard/atomic.js | 2 +- react/src/components/dashboard/sendCoin.js | 20 ++++++------- .../components/dashboard/walletsNativeSend.js | 4 +-- react/src/components/toaster/toaster-item.js | 9 ++---- 38 files changed, 115 insertions(+), 121 deletions(-) diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index fc91713..afad134 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -190,10 +190,9 @@ export function toggleSendReceiveCoinFormsState() { } } -export function triggerToaster(display, message, title, _type, autoClose = true) { +export function triggerToaster(message, title, _type, autoClose = true) { return { type: ADD_TOASTER_MESSAGE, - display, message, title, _type, @@ -295,7 +294,7 @@ export function rpcErrorHandler(json, dispatch) { if (json && json.error) { if (json.error === 'bitcoinrpc needs coin that is active') { - dispatch(triggerToaster(true, 'No active coin', translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); + dispatch(triggerToaster('No active coin', translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); } } } diff --git a/react/src/actions/actions/addCoin.js b/react/src/actions/actions/addCoin.js index de68e0a..6e19d7d 100644 --- a/react/src/actions/actions/addCoin.js +++ b/react/src/actions/actions/addCoin.js @@ -95,7 +95,7 @@ export function iguanaAddCoin(coin, mode, acData, port) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, translate('TOASTR.FAILED_TO_ADDCOIN'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error')); + dispatch(triggerToaster(translate('TOASTR.FAILED_TO_ADDCOIN'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error')); }) .then(response => response.json()) .then(json => { @@ -176,7 +176,7 @@ export function shepherdHerd(coin, mode, path) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, translate('FAILED_SHEPHERD_HERD'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); + dispatch(triggerToaster(translate('FAILED_SHEPHERD_HERD'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); }) .then(response => response.json()) .then(json => dispatch(iguanaAddCoin(coin, mode, acData))); @@ -191,7 +191,7 @@ export function addCoinResult(coin, mode) { }; return dispatch => { - dispatch(triggerToaster(true, `${coin} ${translate('TOASTR.STARTED_IN')} ${modeToValue[mode]} ${translate('TOASTR.MODE')}`, translate('TOASTR.COIN_NOTIFICATION'), 'success')); + dispatch(triggerToaster(`${coin} ${translate('TOASTR.STARTED_IN')} ${modeToValue[mode]} ${translate('TOASTR.MODE')}`, translate('TOASTR.COIN_NOTIFICATION'), 'success')); dispatch(toggleAddcoinModal(false, false)); dispatch(getDexCoins()); } @@ -208,7 +208,7 @@ export function _shepherdGetConfig(coin, mode) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error')); + dispatch(triggerToaster('Failed to get mode config', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(shepherdHerd(coin, mode, json))); @@ -228,7 +228,7 @@ export function shepherdGetConfig(coin, mode) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'Failed to get KMD config', 'Error', 'error')); + dispatch(triggerToaster('Failed to get KMD config', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(shepherdHerd(coin, mode, json))) @@ -244,7 +244,7 @@ export function shepherdGetConfig(coin, mode) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error')); + dispatch(triggerToaster('Failed to get mode config', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(shepherdHerd(coin, mode, json))); diff --git a/react/src/actions/actions/addressBalance.js b/react/src/actions/actions/addressBalance.js index ad77083..843e2d6 100644 --- a/react/src/actions/actions/addressBalance.js +++ b/react/src/actions/actions/addressBalance.js @@ -89,7 +89,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'getKMDAddressesNative+addresslist+cache', 'Error', 'error')); + dispatch(triggerToaster('getKMDAddressesNative+addresslist+cache', 'Error', 'error')); }) .then(response => response.json()) .then(function(json) { @@ -121,7 +121,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getKMDAddressesNative', 'Error', 'error')); + dispatch(triggerToaster('getKMDAddressesNative', 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -296,7 +296,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getKMDAddressesNative+ZBalance', 'Error', 'error')); + dispatch(triggerToaster('getKMDAddressesNative+ZBalance', 'Error', 'error')); }) .then(response => response.json()) .then(function(json) { @@ -308,7 +308,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'status': 'error', 'response': json, })); - dispatch(triggerToaster(true, 'getKMDAddressesNative+ZBalance', 'Error', 'error')); + dispatch(triggerToaster('getKMDAddressesNative+ZBalance', 'Error', 'error')); } else { resolve(json); newAddressArray[1][index] = { @@ -351,7 +351,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'getKMDAddressesNative+addresslist+cache', 'Error', 'error')); + dispatch(triggerToaster('getKMDAddressesNative+addresslist+cache', 'Error', 'error')); }) .then(response => response.json()) .then(function(json) { @@ -383,7 +383,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error')); + dispatch(triggerToaster('getKMDAddressesNative+Balance', 'Error', 'error')); }) .then(response => response.json()) .then(function(json) { @@ -424,7 +424,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error')); + dispatch(triggerToaster('getKMDAddressesNative+Balance', 'Error', 'error')); }) .then(response => response.json()) .then(function(json) { diff --git a/react/src/actions/actions/atomic.js b/react/src/actions/actions/atomic.js index 7330d1e..76a70e0 100644 --- a/react/src/actions/actions/atomic.js +++ b/react/src/actions/actions/atomic.js @@ -31,7 +31,7 @@ export function atomic(payload) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, payload.method, 'Atomic Explorer error', 'error')); + dispatch(triggerToaster(payload.method, 'Atomic Explorer error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/basiliskCache.js b/react/src/actions/actions/basiliskCache.js index 05834b2..84c3c71 100644 --- a/react/src/actions/actions/basiliskCache.js +++ b/react/src/actions/actions/basiliskCache.js @@ -19,7 +19,7 @@ export function deleteCacheFile(_payload) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'deleteCacheFile', 'Error', 'error')) + dispatch(triggerToaster('deleteCacheFile', 'Error', 'error')) }) .then(response => response.json()) .then(json => dispatch(fetchNewCacheData(_payload))); @@ -38,7 +38,7 @@ export function getCacheFile(pubkey) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'getCacheFile', 'Error', 'error')) + dispatch(triggerToaster('getCacheFile', 'Error', 'error')) }) .then(response => response.json()) .then(json => resolve(json)) @@ -63,7 +63,7 @@ export function fetchNewCacheData(_payload) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'fetchNewCacheData', 'Error', 'error')); + dispatch(triggerToaster('fetchNewCacheData', 'Error', 'error')); }) .then(response => response.json()) .then(json => console.log(json)) @@ -80,7 +80,7 @@ export function getShepherdCache(pubkey, coin) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'getShepherdCache', 'Error', 'error')); + dispatch(triggerToaster('getShepherdCache', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(getShepherdCacheState(json, pubkey, coin))) @@ -125,7 +125,7 @@ export function fetchUtxoCache(_payload) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'fetchNewCacheData', 'Error', 'error')); + dispatch(triggerToaster('fetchNewCacheData', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(getShepherdCache(_pubkey))) @@ -146,7 +146,7 @@ export function shepherdGroomPost(_filename, _payload) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'shepherdGroomPost', 'Error', 'error')); + dispatch(triggerToaster('shepherdGroomPost', 'Error', 'error')); }) .then(response => response.json()) .then(json => console.log(json)) @@ -167,7 +167,7 @@ export function shepherdGroomPostPromise(_filename, _payload) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'shepherdGroomPostPromise', 'Error', 'error')); + dispatch(triggerToaster('shepherdGroomPostPromise', 'Error', 'error')); }) .then(response => response.json()) .then(json => resolve(json)) diff --git a/react/src/actions/actions/basiliskProcessAddress.js b/react/src/actions/actions/basiliskProcessAddress.js index 320296f..f628cff 100644 --- a/react/src/actions/actions/basiliskProcessAddress.js +++ b/react/src/actions/actions/basiliskProcessAddress.js @@ -39,7 +39,7 @@ export function checkAddressBasilisk(coin, address) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'checkAddressBasilisk', 'Error', 'error')); + dispatch(triggerToaster('checkAddressBasilisk', 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -57,7 +57,7 @@ function checkAddressBasiliskHandle(json) { if (json && json.error) { return dispatch => { - dispatch(triggerToaster(true, json.error, translate('TOASTR.WALLET_NOTIFICATION'), 'error')); + dispatch(triggerToaster(json.error, translate('TOASTR.WALLET_NOTIFICATION'), 'error')); } } @@ -65,7 +65,7 @@ function checkAddressBasiliskHandle(json) { json.coin && json.randipbits) { return dispatch => { - dispatch(triggerToaster(true, 'Address already registered', translate('TOASTR.WALLET_NOTIFICATION'), 'warning')); + dispatch(triggerToaster('Address already registered', translate('TOASTR.WALLET_NOTIFICATION'), 'warning')); } } } @@ -101,7 +101,7 @@ export function validateAddressBasilisk(coin, address) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'validateAddressBasilisk', 'Error', 'error')); + dispatch(triggerToaster('validateAddressBasilisk', 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -118,16 +118,16 @@ export function validateAddressBasilisk(coin, address) { function validateAddressBasiliskHandle(json) { return dispatch => { if (json.iswatchonly === true) { - dispatch(triggerToaster(true, translate('TOASTR.VALIDATION_SUCCESS'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error')); + dispatch(triggerToaster(translate('TOASTR.VALIDATION_SUCCESS'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error')); } if (json.iswatchonly === false) { - dispatch(triggerToaster(true, translate('TOASTR.ADDR_ISNT_REG'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error')); + dispatch(triggerToaster(translate('TOASTR.ADDR_ISNT_REG'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error')); } if (json.iswatchonly === undefined) { - dispatch(triggerToaster(true, translate('TOASTR.INVALID_QUERY_ALT'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error')); + dispatch(triggerToaster(translate('TOASTR.INVALID_QUERY_ALT'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error')); } if (json.error === 'less than required responses') { - dispatch(triggerToaster(true, translate('TOASTR.LESS_RESPONSES_REQ'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error')); + dispatch(triggerToaster(translate('TOASTR.LESS_RESPONSES_REQ'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error')); } } } \ No newline at end of file diff --git a/react/src/actions/actions/basiliskTxHistory.js b/react/src/actions/actions/basiliskTxHistory.js index 8edcbe1..f68407f 100644 --- a/react/src/actions/actions/basiliskTxHistory.js +++ b/react/src/actions/actions/basiliskTxHistory.js @@ -20,7 +20,7 @@ export function getBasiliskTransactionsList(coin, address) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'getBasiliskTransactionsList+cache', 'Error', 'error')); + dispatch(triggerToaster('getBasiliskTransactionsList+cache', 'Error', 'error')); }) .then(response => response.json()) .then(function(json) { diff --git a/react/src/actions/actions/cli.js b/react/src/actions/actions/cli.js index 4ac228a..9f35fe2 100644 --- a/react/src/actions/actions/cli.js +++ b/react/src/actions/actions/cli.js @@ -25,7 +25,7 @@ export function shepherdCliPromise(mode, chain, cmd) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'shepherdCli', 'Error', 'error')); + dispatch(triggerToaster('shepherdCli', 'Error', 'error')); }) .then(response => response.json()) .then(json => resolve(json)) @@ -49,7 +49,7 @@ export function shepherdCli(mode, chain, cmd) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'shepherdCli', 'Error', 'error')); + dispatch(triggerToaster('shepherdCli', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(cliResponseState(json))) diff --git a/react/src/actions/actions/coinList.js b/react/src/actions/actions/coinList.js index c17a072..4a81a90 100644 --- a/react/src/actions/actions/coinList.js +++ b/react/src/actions/actions/coinList.js @@ -17,7 +17,7 @@ export function shepherdGetCoinList() { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'shepherdGetCoinList', 'Error', 'error')); + dispatch(triggerToaster('shepherdGetCoinList', 'Error', 'error')); }) .then(response => response.json()) .then(json => resolve(json)) @@ -35,7 +35,7 @@ export function shepherdPostCoinList(data) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'shepherdPostCoinList', 'Error', 'error')); + dispatch(triggerToaster('shepherdPostCoinList', 'Error', 'error')); }) .then(response => response.json()) .then(json => resolve(json)) diff --git a/react/src/actions/actions/copyAddress.js b/react/src/actions/actions/copyAddress.js index 7f3f9d3..56f374f 100644 --- a/react/src/actions/actions/copyAddress.js +++ b/react/src/actions/actions/copyAddress.js @@ -7,11 +7,11 @@ export function copyCoinAddress(address) { if (_result) { return dispatch => { - dispatch(triggerToaster(true, translate('DASHBOARD.ADDR_COPIED'), translate('TOASTR.COIN_NOTIFICATION'), 'success')); + dispatch(triggerToaster(translate('DASHBOARD.ADDR_COPIED'), translate('TOASTR.COIN_NOTIFICATION'), 'success')); } } else { return dispatch => { - dispatch(triggerToaster(true, 'Couldn\'t copy address to clipboard', translate('TOASTR.COIN_NOTIFICATION'), 'error')); + dispatch(triggerToaster('Couldn\'t copy address to clipboard', translate('TOASTR.COIN_NOTIFICATION'), 'error')); } } } \ No newline at end of file diff --git a/react/src/actions/actions/createWallet.js b/react/src/actions/actions/createWallet.js index 29b2796..934cba4 100644 --- a/react/src/actions/actions/createWallet.js +++ b/react/src/actions/actions/createWallet.js @@ -13,11 +13,11 @@ function createNewWalletState(json) { json.result && json.result === 'success') { return dispatch => { - dispatch(triggerToaster(true, translate('TOASTR.WALLET_CREATED_SUCCESFULLY'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'success')); + dispatch(triggerToaster(translate('TOASTR.WALLET_CREATED_SUCCESFULLY'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'success')); } } else { return dispatch => { - dispatch(triggerToaster(true, 'Couldn\'t create new wallet seed', translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error')); + dispatch(triggerToaster('Couldn\'t create new wallet seed', translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error')); } } } @@ -52,7 +52,7 @@ export function createNewWallet(_passphrase) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'createNewWallet', 'Error', 'error')); + dispatch(triggerToaster('createNewWallet', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/dexCoins.js b/react/src/actions/actions/dexCoins.js index eaf13c8..52c16f0 100644 --- a/react/src/actions/actions/dexCoins.js +++ b/react/src/actions/actions/dexCoins.js @@ -37,7 +37,7 @@ export function getDexCoins() { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'Error getDexCoins', 'Error', 'error')); + dispatch(triggerToaster('Error getDexCoins', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/edexBalance.js b/react/src/actions/actions/edexBalance.js index 87f7aaa..40c2fc0 100644 --- a/react/src/actions/actions/edexBalance.js +++ b/react/src/actions/actions/edexBalance.js @@ -39,7 +39,7 @@ export function iguanaEdexBalance(coin) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'Error iguanaEdexBalance', 'Error', 'error')); + dispatch(triggerToaster('Error iguanaEdexBalance', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(iguanaEdexBalanceState(json))); @@ -86,7 +86,7 @@ export function getDexBalance(coin, mode, addr) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getDexBalance', 'Error', 'error')); + dispatch(triggerToaster('getDexBalance', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/edexGetTx.js b/react/src/actions/actions/edexGetTx.js index 21336cc..bf19636 100644 --- a/react/src/actions/actions/edexGetTx.js +++ b/react/src/actions/actions/edexGetTx.js @@ -39,7 +39,7 @@ export function edexGetTransaction(data, dispatch) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'edexGetTransaction', 'Error', 'error')); + dispatch(triggerToaster('edexGetTransaction', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/fullTxHistory.js b/react/src/actions/actions/fullTxHistory.js index bfc266f..f3d224c 100644 --- a/react/src/actions/actions/fullTxHistory.js +++ b/react/src/actions/actions/fullTxHistory.js @@ -42,7 +42,7 @@ export function getFullTransactionsList(coin) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getFullTransactionsList', 'Error', 'error')); + dispatch(triggerToaster('getFullTransactionsList', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/getAddrByAccount.js b/react/src/actions/actions/getAddrByAccount.js index 4e4cfb1..828f0d3 100644 --- a/react/src/actions/actions/getAddrByAccount.js +++ b/react/src/actions/actions/getAddrByAccount.js @@ -61,7 +61,7 @@ export function getAddressesByAccount(coin, mode) { 'response': error, })); dispatch(updateErrosStack('activeHandle')); - dispatch(triggerToaster(true, 'getAddressesByAccount', 'Error', 'error')); + dispatch(triggerToaster('getAddressesByAccount', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/iguanaHelpers.js b/react/src/actions/actions/iguanaHelpers.js index 3f36266..93094ea 100644 --- a/react/src/actions/actions/iguanaHelpers.js +++ b/react/src/actions/actions/iguanaHelpers.js @@ -49,7 +49,7 @@ export function iguanaHashHex(data, dispatch) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'iguanaHashHex', 'Error', 'error')); + dispatch(triggerToaster('iguanaHashHex', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/iguanaInstance.js b/react/src/actions/actions/iguanaInstance.js index 04c817b..d5adb93 100644 --- a/react/src/actions/actions/iguanaInstance.js +++ b/react/src/actions/actions/iguanaInstance.js @@ -17,7 +17,7 @@ export function restartIguanaInstance(pmid) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'restartIguanaInstance', 'Error', 'error')); + dispatch(triggerToaster('restartIguanaInstance', 'Error', 'error')); }) .then(response => response.json()) .then(json => resolve(json)) @@ -54,7 +54,7 @@ export function startIguanaInstance(mode, coin) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'startIguanaInstance', 'Error', 'error')); + dispatch(triggerToaster('startIguanaInstance', 'Error', 'error')); }) .then(response => response.json()) .then(json => resolve(json)) @@ -71,7 +71,7 @@ export function getIguanaInstancesList() { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'getIguanaInstanceList', 'Error', 'error')); + dispatch(triggerToaster('getIguanaInstanceList', 'Error', 'error')); }) .then(response => response.json()) .then(json => resolve(json)) diff --git a/react/src/actions/actions/log.js b/react/src/actions/actions/log.js index eda0db6..8891290 100644 --- a/react/src/actions/actions/log.js +++ b/react/src/actions/actions/log.js @@ -18,7 +18,7 @@ export function logGuiHttp(payload) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'logGuiHttp', 'Error', 'error')); + dispatch(triggerToaster('logGuiHttp', 'Error', 'error')); }) .then(response => response.json())*/ } @@ -34,7 +34,7 @@ export function getAgamaLog(type) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'getAgamaLog', 'Error', 'error')); + dispatch(triggerToaster('getAgamaLog', 'Error', 'error')); }) .then(response => response.json()) .then() diff --git a/react/src/actions/actions/logout.js b/react/src/actions/actions/logout.js index d391b89..f421efb 100644 --- a/react/src/actions/actions/logout.js +++ b/react/src/actions/actions/logout.js @@ -52,7 +52,7 @@ function walletLock() { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'walletLock', 'Error', 'error')); + dispatch(triggerToaster('walletLock', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/nativeBalance.js b/react/src/actions/actions/nativeBalance.js index 2819d52..de2c7b1 100644 --- a/react/src/actions/actions/nativeBalance.js +++ b/react/src/actions/actions/nativeBalance.js @@ -54,7 +54,7 @@ export function getKMDBalanceTotal(coin) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getKMDBalanceTotal', 'Error', 'error')); + dispatch(triggerToaster('getKMDBalanceTotal', 'Error', 'error')); }) .then(response => response.json()) .then(function(json) { // TODO: figure out why komodod spits out "parse error" diff --git a/react/src/actions/actions/nativeNewAddress.js b/react/src/actions/actions/nativeNewAddress.js index bec0473..d278c21 100644 --- a/react/src/actions/actions/nativeNewAddress.js +++ b/react/src/actions/actions/nativeNewAddress.js @@ -11,7 +11,7 @@ import { } from './log'; function handleGetNewKMDAddresses(pubpriv, coin, dispatch) { - dispatch(triggerToaster(true, translate('KMD_NATIVE.NEW_ADDR_GENERATED'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')); + dispatch(triggerToaster(translate('KMD_NATIVE.NEW_ADDR_GENERATED'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')); dispatch(getKMDAddressesNative(coin)); return {}; @@ -69,7 +69,7 @@ export function getNewKMDAddresses(coin, pubpriv) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getNewKMDAddresses', 'Error', 'error')); + dispatch(triggerToaster('getNewKMDAddresses', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/nativeSend.js b/react/src/actions/actions/nativeSend.js index 0ed5002..57ab44a 100644 --- a/react/src/actions/actions/nativeSend.js +++ b/react/src/actions/actions/nativeSend.js @@ -67,7 +67,7 @@ export function sendNativeTx(coin, _payload) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'sendNativeTx', 'Error', 'error')); + dispatch(triggerToaster('sendNativeTx', 'Error', 'error')); }) .then(function(response) { const _response = response.text().then(function(text) { return text; }); @@ -82,9 +82,9 @@ export function sendNativeTx(coin, _payload) { if (json.error && json.error.toString().indexOf('code:') > -1) { - dispatch(triggerToaster(true, 'Send failed', translate('TOASTR.WALLET_NOTIFICATION'), 'error')); + dispatch(triggerToaster('Send failed', translate('TOASTR.WALLET_NOTIFICATION'), 'error')); } else { - dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')); + dispatch(triggerToaster(translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')); } }) }); @@ -158,7 +158,7 @@ export function getKMDOPID(opid, coin) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getKMDOPID', 'Error', 'error')); + dispatch(triggerToaster('getKMDOPID', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/nativeSyncInfo.js b/react/src/actions/actions/nativeSyncInfo.js index 042842a..7a4abff 100644 --- a/react/src/actions/actions/nativeSyncInfo.js +++ b/react/src/actions/actions/nativeSyncInfo.js @@ -34,7 +34,7 @@ export function getSyncInfoNativeKMD(skipDebug) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getSyncInfoNativeKMD', 'Error', 'error')); + dispatch(triggerToaster('getSyncInfoNativeKMD', 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -98,7 +98,7 @@ export function getSyncInfoNative(coin, skipDebug) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error')); + dispatch(triggerToaster('getSyncInfo', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/nativeTxHistory.js b/react/src/actions/actions/nativeTxHistory.js index 5e86753..1708ce2 100644 --- a/react/src/actions/actions/nativeTxHistory.js +++ b/react/src/actions/actions/nativeTxHistory.js @@ -53,7 +53,7 @@ export function getNativeTxHistory(coin) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getNativeTxHistory', 'Error', 'error')); + dispatch(triggerToaster('getNativeTxHistory', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/notary.js b/react/src/actions/actions/notary.js index 591df50..a9ebf87 100644 --- a/react/src/actions/actions/notary.js +++ b/react/src/actions/actions/notary.js @@ -44,7 +44,7 @@ function initNotaryNodesConSequence(nodes) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, `getInfoDexNode+${node}`, 'Error', 'error')); + dispatch(triggerToaster(`getInfoDexNode+${node}`, 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -114,7 +114,7 @@ export function connectNotaries() { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'connectNotaries', 'Error', 'error')); + dispatch(triggerToaster('connectNotaries', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(connectAllNotaryNodes(json, dispatch))) @@ -124,7 +124,7 @@ export function connectNotaries() { function getDexNotariesState(json) { if (json.error === 'less than required responses') { return dispatch => { - dispatch(triggerToaster(true, translate('TOASTR.LESS_RESPONSES_REQ'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error')); + dispatch(triggerToaster(translate('TOASTR.LESS_RESPONSES_REQ'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error')); } } else { return { @@ -163,7 +163,7 @@ export function getDexNotaries(coin) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getDexNotaries', 'Error', 'error')); + dispatch(triggerToaster('getDexNotaries', 'Error', 'error')); }) .then(response => response.json()) .then(json => { diff --git a/react/src/actions/actions/openAlias.js b/react/src/actions/actions/openAlias.js index d562e4f..3dc2ff3 100644 --- a/react/src/actions/actions/openAlias.js +++ b/react/src/actions/actions/openAlias.js @@ -13,7 +13,7 @@ export function resolveOpenAliasAddress(email) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'resolveOpenAliasAddress', 'Error', 'error')); + dispatch(triggerToaster('resolveOpenAliasAddress', 'Error', 'error')); }) .then(response => response.json()) .then(json => resolve(json)) diff --git a/react/src/actions/actions/sendFullBasilisk.js b/react/src/actions/actions/sendFullBasilisk.js index 282f6d4..8402bcb 100644 --- a/react/src/actions/actions/sendFullBasilisk.js +++ b/react/src/actions/actions/sendFullBasilisk.js @@ -45,7 +45,7 @@ export function sendToAddress(coin, _payload) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'sendToAddress', 'Error', 'error')); + dispatch(triggerToaster('sendToAddress', 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -95,7 +95,7 @@ export function sendFromAddress(coin, _payload) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'sendFromAddress', 'Error', 'error')); + dispatch(triggerToaster('sendFromAddress', 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -148,7 +148,7 @@ export function iguanaUTXORawTX(data, dispatch) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'iguanaUTXORawTX', 'Error', 'error')); + dispatch(triggerToaster('iguanaUTXORawTX', 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -193,7 +193,7 @@ export function dexSendRawTX(data, dispatch) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'dexSendRawTX', 'Error', 'error')); + dispatch(triggerToaster('dexSendRawTX', 'Error', 'error')); }) .then(function(response) { const _response = response.text().then(function(text) { return text; }); @@ -214,14 +214,14 @@ export function dexSendRawTX(data, dispatch) { function sendToAddressState(json, dispatch) { if (json && json.error) { - dispatch(triggerToaster(true, json.error, 'Error', 'error')); + dispatch(triggerToaster(json.error, 'Error', 'error')); return { type: DASHBOARD_ACTIVE_COIN_SENDTO, lastSendToResponse: json, } } else if (json && json.result && json.complete) { - dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')); + dispatch(triggerToaster(translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')); return { type: DASHBOARD_ACTIVE_COIN_SENDTO, diff --git a/react/src/actions/actions/settings.js b/react/src/actions/actions/settings.js index 6f61fe4..1dd4e09 100644 --- a/react/src/actions/actions/settings.js +++ b/react/src/actions/actions/settings.js @@ -32,7 +32,7 @@ export function getAppInfo() { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'getAppInfo', 'Error', 'error')); + dispatch(triggerToaster('getAppInfo', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(getAppInfoState(json))) @@ -50,19 +50,19 @@ export function settingsWifkeyState(json, coin) { function parseImportPrivKeyResponse(json, dispatch) { if (json.error === 'illegal privkey') { return dispatch => { - dispatch(triggerToaster(true, 'Illegal privkey', translate('TOASTR.SETTINGS_NOTIFICATION'), 'error')); + dispatch(triggerToaster('Illegal privkey', translate('TOASTR.SETTINGS_NOTIFICATION'), 'error')); } } if (json.error === 'privkey already in wallet') { return dispatch => { - dispatch(triggerToaster(true, 'Privkey already in wallet', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning')); + dispatch(triggerToaster('Privkey already in wallet', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning')); } } if (json && json.result !== undefined && json.result == 'success') { return dispatch => { - dispatch(triggerToaster(true, translate('TOASTR.PRIV_KEY_IMPORTED'), translate('TOASTR.SETTINGS_NOTIFICATION'), 'success')); + dispatch(triggerToaster(translate('TOASTR.PRIV_KEY_IMPORTED'), translate('TOASTR.SETTINGS_NOTIFICATION'), 'success')); } } } @@ -99,7 +99,7 @@ export function importPrivKey(wifKey) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'importPrivKey', 'Error', 'error')); + dispatch(triggerToaster('importPrivKey', 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -144,7 +144,7 @@ export function getDebugLog(target, linesCount) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'getDebugLog', 'Error', 'error')); + dispatch(triggerToaster('getDebugLog', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(getDebugLogState(json))) @@ -181,7 +181,7 @@ export function getPeersList(coin) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getPeersList', 'Error', 'error')); + dispatch(triggerToaster('getPeersList', 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -216,22 +216,22 @@ export function getPeersListState(json) { function addPeerNodeState(json, dispatch) { if (json.error === 'addnode needs active coin, do an addcoin first') { return dispatch => { - dispatch(triggerToaster(true, 'Addnode needs active coin', translate('TOASTR.SETTINGS_NOTIFICATION'), 'error')); + dispatch(triggerToaster('Addnode needs active coin', translate('TOASTR.SETTINGS_NOTIFICATION'), 'error')); } } if (json.result === 'peer was already connected') { return dispatch => { - dispatch(triggerToaster(true, 'Peer was already connected', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning')); + dispatch(triggerToaster('Peer was already connected', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning')); } } if (json.result === 'addnode connection was already pending') { return dispatch => { - dispatch(triggerToaster(true, 'Addnode connection was already pending', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning')); + dispatch(triggerToaster('Addnode connection was already pending', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning')); } } if (json.result === 'addnode submitted') { return dispatch => { - dispatch(triggerToaster(true, 'Peer is added', translate('TOASTR.SETTINGS_NOTIFICATION'), 'success')); + dispatch(triggerToaster('Peer is added', translate('TOASTR.SETTINGS_NOTIFICATION'), 'success')); } } } @@ -267,7 +267,7 @@ export function addPeerNode(coin, ip) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'addPeerNode', 'Error', 'error')); + dispatch(triggerToaster('addPeerNode', 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -292,7 +292,7 @@ export function saveAppConfig(_payload) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'saveAppConfig', 'Error', 'error')); + dispatch(triggerToaster('saveAppConfig', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(getAppConfig())) @@ -316,7 +316,7 @@ export function getAppConfig() { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'getAppConfig', 'Error', 'error')); + dispatch(triggerToaster('getAppConfig', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(getAppConfigState(json))) diff --git a/react/src/actions/actions/syncInfo.js b/react/src/actions/actions/syncInfo.js index a9ff460..a6768c5 100644 --- a/react/src/actions/actions/syncInfo.js +++ b/react/src/actions/actions/syncInfo.js @@ -53,7 +53,7 @@ export function getSyncInfo(coin) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error')); + dispatch(triggerToaster('getSyncInfo', 'Error', 'error')); }) .then(function(response) { const _response = response.text().then(function(text) { return text; }); diff --git a/react/src/actions/actions/syncOnly.js b/react/src/actions/actions/syncOnly.js index d43e29b..18f0b5c 100644 --- a/react/src/actions/actions/syncOnly.js +++ b/react/src/actions/actions/syncOnly.js @@ -36,7 +36,7 @@ export function getSyncOnlyForks() { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'getSyncOnlyForks', 'Error', 'error')); + dispatch(triggerToaster('getSyncOnlyForks', 'Error', 'error')); }) .then(response => response.json()) .then(json => dispatch(getSyncOnlyForksState(json))) @@ -53,9 +53,9 @@ export function stopIguanaFork(pmid) { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'stopIguanaFork', 'Error', 'error')); + dispatch(triggerToaster('stopIguanaFork', 'Error', 'error')); }) .then(response => response.json()) - .then(json => dispatch(triggerToaster(true, 'Iguana instance is stopped', translate('TOASTR.SERVICE_NOTIFICATION'), 'success'))) + .then(json => dispatch(triggerToaster('Iguana instance is stopped', translate('TOASTR.SERVICE_NOTIFICATION'), 'success'))) } } \ No newline at end of file diff --git a/react/src/actions/actions/sysInfo.js b/react/src/actions/actions/sysInfo.js index 42f601d..75068e9 100644 --- a/react/src/actions/actions/sysInfo.js +++ b/react/src/actions/actions/sysInfo.js @@ -17,7 +17,7 @@ export function shepherdGetSysInfo() { }) .catch(function(error) { console.log(error); - dispatch(triggerToaster(true, 'Failed to get sys info', 'Error', 'error')) + dispatch(triggerToaster('Failed to get sys info', 'Error', 'error')) }) .then(response => response.json()) .then(json => console.log(json)); diff --git a/react/src/actions/actions/walletAuth.js b/react/src/actions/actions/walletAuth.js index a9fe0a7..02db498 100644 --- a/react/src/actions/actions/walletAuth.js +++ b/react/src/actions/actions/walletAuth.js @@ -44,7 +44,7 @@ export function encryptWallet(_passphrase, cb, coin) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'encryptWallet', 'Error', 'error')); + dispatch(triggerToaster('encryptWallet', 'Error', 'error')); }) .then(dispatch(walletPassphrase(_passphrase))) .then(response => response.json()) @@ -90,7 +90,7 @@ export function walletPassphrase(_passphrase) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'walletPassphrase', 'Error', 'error')); + dispatch(triggerToaster('walletPassphrase', 'Error', 'error')); }) .then(json => { dispatch(logGuiHttp({ @@ -134,7 +134,7 @@ export function iguanaWalletPassphrase(_passphrase) { 'status': 'error', 'response': error, })); - dispatch(triggerToaster(true, 'Error iguanaWalletPassphrase', 'Error', 'error')); + dispatch(triggerToaster('Error iguanaWalletPassphrase', 'Error', 'error')); }) .then(response => response.json()) .then(json => { @@ -178,7 +178,7 @@ export function iguanaActiveHandle(getMainAddress) { 'response': error, })); dispatch(updateErrosStack('activeHandle')); - dispatch(triggerToaster(true, translate('TOASTR.IGUANA_ARE_YOU_SURE'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); + dispatch(triggerToaster(translate('TOASTR.IGUANA_ARE_YOU_SURE'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); }) .then(response => response.json()) .then(json => { @@ -194,7 +194,7 @@ export function iguanaActiveHandle(getMainAddress) { function iguanaWalletPassphraseState(json, dispatch) { sessionStorage.setItem('IguanaActiveAccount', JSON.stringify(json)); - dispatch(triggerToaster(true, translate('TOASTR.LOGIN_SUCCESSFULL'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'success')); + dispatch(triggerToaster(translate('TOASTR.LOGIN_SUCCESSFULL'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'success')); dispatch(getMainAddressState(json)); dispatch(iguanaActiveHandleState(json)); diff --git a/react/src/components/addcoin/addcoin.js b/react/src/components/addcoin/addcoin.js index 7b750a6..3d7fd68 100644 --- a/react/src/components/addcoin/addcoin.js +++ b/react/src/components/addcoin/addcoin.js @@ -63,7 +63,7 @@ class AddCoin extends React.Component { actionsMenu: false, })); } else { - Store.dispatch(triggerToaster(true, translate('TOASTR.SELECTION_NOT_FOUND'), translate('TOASTR.COIN_SELECTION'), 'info')); + Store.dispatch(triggerToaster(translate('TOASTR.SELECTION_NOT_FOUND'), translate('TOASTR.COIN_SELECTION'), 'info')); } }.bind(this)); } diff --git a/react/src/components/dashboard/atomic.js b/react/src/components/dashboard/atomic.js index 4708966..96a7294 100755 --- a/react/src/components/dashboard/atomic.js +++ b/react/src/components/dashboard/atomic.js @@ -340,7 +340,7 @@ class Atomic extends React.Component { } if (props.Atomic.response.error === 'less than required responses') { - Store.dispatch(triggerToaster(true, 'Basilisk connection error', translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); + Store.dispatch(triggerToaster('Basilisk connection error', translate('TOASTR.SERVICE_NOTIFICATION'), 'error')); } } } diff --git a/react/src/components/dashboard/sendCoin.js b/react/src/components/dashboard/sendCoin.js index d98364c..36f014a 100644 --- a/react/src/components/dashboard/sendCoin.js +++ b/react/src/components/dashboard/sendCoin.js @@ -394,7 +394,7 @@ class SendCoin extends React.Component { console.log('iguanaUTXORawTXJSON', json); if (json.result === 'success' && json.completed === true) { - Store.dispatch(triggerToaster(true, translate('TOASTR.SIGNED_TX_GENERATED') + '.', translate('TOASTR.WALLET_NOTIFICATION'), 'success')); + Store.dispatch(triggerToaster(translate('TOASTR.SIGNED_TX_GENERATED') + '.', translate('TOASTR.WALLET_NOTIFICATION'), 'success')); if (sendData.sendsig === 1) { const dexrawtxData = { @@ -405,19 +405,19 @@ class SendCoin extends React.Component { .then(function(dexRawTxJSON) { console.log('dexRawTxJSON', dexRawTxJSON); if (dexRawTxJSON.indexOf('"error":{"code"') > -1) { - Store.dispatch(triggerToaster(true, 'Transaction failed', translate('TOASTR.WALLET_NOTIFICATION'), 'error')); + Store.dispatch(triggerToaster('Transaction failed', translate('TOASTR.WALLET_NOTIFICATION'), 'error')); Store.dispatch(sendToAddressStateAlt(JSON.parse(dexRawTxJSON))); this.setState(Object.assign({}, this.state, { utxoMethodInProgress: false, })); } else { - Store.dispatch(triggerToaster(true, translate('TOASTR.SIGNED_TX_SENT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')); + Store.dispatch(triggerToaster(translate('TOASTR.SIGNED_TX_SENT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')); Store.dispatch(sendToAddressStateAlt(json)); let getTxidData = function() { return new Promise(function(resolve, reject) { - Store.dispatch(triggerToaster(true, translate('TOASTR.GETTING_TXID_INFO') + '.', translate('TOASTR.WALLET_NOTIFICATION'), 'info')); + Store.dispatch(triggerToaster(translate('TOASTR.GETTING_TXID_INFO') + '.', translate('TOASTR.WALLET_NOTIFICATION'), 'info')); edexGetTransaction({ 'coin': sendData.coin, @@ -464,7 +464,7 @@ class SendCoin extends React.Component { console.log(result); resolve(result); forceUpdateCache(); - Store.dispatch(triggerToaster(true, translate('TOASTR.LOCAL_UTXO_UPDATED'), translate('TOASTR.WALLET_NOTIFICATION'), 'info')); + Store.dispatch(triggerToaster(translate('TOASTR.LOCAL_UTXO_UPDATED'), translate('TOASTR.WALLET_NOTIFICATION'), 'info')); this.setState(Object.assign({}, this.state, { utxoMethodInProgress: false, @@ -473,10 +473,10 @@ class SendCoin extends React.Component { }.bind(this)); }.bind(this); - Store.dispatch(triggerToaster(true, translate('TOASTR.AWAITING_TX_RESP') + '...', translate('TOASTR.WALLET_NOTIFICATION'), 'info')); + Store.dispatch(triggerToaster(translate('TOASTR.AWAITING_TX_RESP') + '...', translate('TOASTR.WALLET_NOTIFICATION'), 'info')); function waterfallUTXOProcess() { - Store.dispatch(triggerToaster(true, translate('TOASTR.PROCESSING_UTXO') + '...', translate('TOASTR.WALLET_NOTIFICATION'), 'info')); + Store.dispatch(triggerToaster(translate('TOASTR.PROCESSING_UTXO') + '...', translate('TOASTR.WALLET_NOTIFICATION'), 'info')); getTxidData() .then(function(gettxdata) { @@ -512,7 +512,7 @@ class SendCoin extends React.Component { } } else { Store.dispatch(sendToAddressStateAlt(json)); - Store.dispatch(triggerToaster(true, translate('TOASTR.SIGNED_TX_GENERATED_FAIL') + '.', translate('TOASTR.WALLET_NOTIFICATION'), 'error')); + Store.dispatch(triggerToaster(translate('TOASTR.SIGNED_TX_GENERATED_FAIL') + '.', translate('TOASTR.WALLET_NOTIFICATION'), 'error')); this.setState(Object.assign({}, this.state, { utxoMethodInProgress: false, @@ -622,10 +622,10 @@ class SendCoin extends React.Component { } if (this.state.sendTo === '') { - Store.dispatch(triggerToaster(true, 'Couldn\'t find any ' + this.props.ActiveCoin.coin + ' addresses', 'OpenAlias', 'error')); + Store.dispatch(triggerToaster('Couldn\'t find any ' + this.props.ActiveCoin.coin + ' addresses', 'OpenAlias', 'error')); } } else { - Store.dispatch(triggerToaster(true, 'Couldn\'t find any addresses', 'OpenAlias', 'error')); + Store.dispatch(triggerToaster('Couldn\'t find any addresses', 'OpenAlias', 'error')); } }.bind(this)); } diff --git a/react/src/components/dashboard/walletsNativeSend.js b/react/src/components/dashboard/walletsNativeSend.js index cd8e1b5..367475e 100644 --- a/react/src/components/dashboard/walletsNativeSend.js +++ b/react/src/components/dashboard/walletsNativeSend.js @@ -218,10 +218,10 @@ class WalletsNativeSend extends React.Component { } if (this.state.sendTo === '') { - Store.dispatch(triggerToaster(true, 'Couldn\'t find any ' + this.props.ActiveCoin.coin + ' addresses', 'OpenAlias', 'error')); + Store.dispatch(triggerToaster('Couldn\'t find any ' + this.props.ActiveCoin.coin + ' addresses', 'OpenAlias', 'error')); } } else { - Store.dispatch(triggerToaster(true, 'Couldn\'t find any addresses', 'OpenAlias', 'error')); + Store.dispatch(triggerToaster('Couldn\'t find any addresses', 'OpenAlias', 'error')); } }); } diff --git a/react/src/components/toaster/toaster-item.js b/react/src/components/toaster/toaster-item.js index 0014504..27165de 100644 --- a/react/src/components/toaster/toaster-item.js +++ b/react/src/components/toaster/toaster-item.js @@ -13,7 +13,6 @@ class ToasterItem extends React.Component { constructor(props) { super(props); this.state = { - display: false, message: null, type: null, title: null, @@ -27,11 +26,9 @@ class ToasterItem extends React.Component { componentWillReceiveProps(props) { if (props && - props.message && - props.display) { + props.message) { this.setState({ message: props.message, - display: props.display, type: props._type, title: props.title, autoClose: props.autoClose, @@ -39,7 +36,6 @@ class ToasterItem extends React.Component { }); } else { this.setState({ - display: false, message: null, type: null, title: null, @@ -74,8 +70,7 @@ class ToasterItem extends React.Component { } render() { - return (this.state.message && this.state.display) ? - this.renderToast() : null; + return this.state.message ? this.renderToast() : null; } } From c260947fbef443edd2245c165f82559c1af6e72d Mon Sep 17 00:00:00 2001 From: petitPapillon Date: Sun, 11 Jun 2017 23:03:09 +0200 Subject: [PATCH 2/3] Coin activation - display an error message when a user tries to add the same coin multiple times (in the same or different mode) --- react/src/components/addcoin/addcoin.js | 61 +++++++++++++++----- react/src/components/main/walletMain.js | 2 +- react/src/components/toaster/toaster-item.js | 11 ++-- react/src/translate/en.js | 6 +- 4 files changed, 57 insertions(+), 23 deletions(-) diff --git a/react/src/components/addcoin/addcoin.js b/react/src/components/addcoin/addcoin.js index 7b750a6..d57aa25 100644 --- a/react/src/components/addcoin/addcoin.js +++ b/react/src/components/addcoin/addcoin.js @@ -38,6 +38,7 @@ class AddCoin extends React.Component { actionsMenu: false, modalClassName: 'hide', }; + this.existingCoins = null; this.activateCoin = this.activateCoin.bind(this); this.dismiss = this.dismiss.bind(this); this.addNewItem = this.addNewItem.bind(this); @@ -91,16 +92,18 @@ class AddCoin extends React.Component { } componentWillReceiveProps(props) { - if (props && props.display !== this.state.display) { + this.existingCoins = props && props.Main ? props.Main.coins : null; + const addCoinProps = props ? props.AddCoin : null; + if (addCoinProps && addCoinProps.display !== this.state.display) { this.setState(Object.assign({}, this.state, { - display: props.display, - modalClassName: props.display ? 'show fade' : 'show fade', + display: addCoinProps.display, + modalClassName: addCoinProps.display ? 'show fade' : 'show fade', })); setTimeout(() => { this.setState(Object.assign({}, this.state, { - display: props.display, - modalClassName: props.display ? 'show in' : 'hide', + display: addCoinProps.display, + modalClassName: addCoinProps.display ? 'show in' : 'hide', })); }, 100); } @@ -172,8 +175,14 @@ class AddCoin extends React.Component { } activateCoin() { + const coin = this.state.coins[0].selectedCoin.split('|')[0]; + if (this.isCoinAlreadyAdded(coin)) { + this.dismiss(); + return; + } + Store.dispatch(addCoin( - this.state.coins[0].selectedCoin.split('|')[0], + coin, this.state.coins[0].mode, this.state.coins[0].syncOnly )); @@ -211,21 +220,27 @@ class AddCoin extends React.Component { } activateAllCoins() { - Store.dispatch(addCoin( - this.state.coins[0].selectedCoin.split('|')[0], - this.state.coins[0].mode, - this.state.coins[0].syncOnly - )); + const coin = this.state.coins[0].selectedCoin.split('|')[0]; + if (!this.isCoinAlreadyAdded(coin)) { + Store.dispatch(addCoin( + coin, + this.state.coins[0].mode, + this.state.coins[0].syncOnly + )); + } for (let i = 1; i < this.state.coins.length; i++) { const _item = this.state.coins[i]; + const itemCoin = _item.selectedCoin.split('|')[0]; setTimeout(() => { - Store.dispatch(addCoin( - _item.selectedCoin.split('|')[0], - _item.mode, - _item.syncOnly - )); + if (!this.isCoinAlreadyAdded(itemCoin)) { + Store.dispatch(addCoin( + itemCoin, + _item.mode, + _item.syncOnly + )); + } if (i === this.state.coins.length - 1) { let _coins = []; @@ -261,6 +276,20 @@ class AddCoin extends React.Component { AddCoinRender.call(this) ); } + + isCoinAlreadyAdded(coin) { + const modes = ['basilisk', 'full', 'native']; + + for (let mode of modes) { + if (this.existingCoins[mode].indexOf(coin) !== -1) { + const message = `${coin} ${translate('ADD_COIN.ALREADY_ADDED')} ${translate('ADD_COIN.IN')} ${mode} ${translate('ADD_COIN.MODE')}`; + Store.dispatch(triggerToaster(true, message, translate('ADD_COIN.COIN_ALREADY_ADDED'), 'error')); + return true; + } + } + + return false; + } } export default AddCoin; diff --git a/react/src/components/main/walletMain.js b/react/src/components/main/walletMain.js index fdc6868..6c291ca 100644 --- a/react/src/components/main/walletMain.js +++ b/react/src/components/main/walletMain.js @@ -12,7 +12,7 @@ class WalletMain extends React.Component {
- + diff --git a/react/src/components/toaster/toaster-item.js b/react/src/components/toaster/toaster-item.js index 0014504..677da57 100644 --- a/react/src/components/toaster/toaster-item.js +++ b/react/src/components/toaster/toaster-item.js @@ -13,11 +13,12 @@ class ToasterItem extends React.Component { constructor(props) { super(props); this.state = { - display: false, - message: null, - type: null, - title: null, - autoClose: true + display: props.display, + message: props.message, + type: props._type, + title: props.title, + autoClose: props.autoClose, + toastId: props.toastId }; this.dismissToast = this.dismissToast.bind(this); diff --git a/react/src/translate/en.js b/react/src/translate/en.js index af3fe3d..a2ee089 100644 --- a/react/src/translate/en.js +++ b/react/src/translate/en.js @@ -221,7 +221,11 @@ export const _lang = { 'SAVE_SELECTION': 'Save Selection', 'LOAD_SELECTION': 'Load Selection', 'ACTIVATE_ALL': 'Activate all', - 'ADD_ANOTHER_COIN': 'Add another coin' + 'ADD_ANOTHER_COIN': 'Add another coin', + 'ALREADY_ADDED': 'is already added', + 'COIN_ALREADY_ADDED': 'Coin already added', + 'IN': 'in', + 'MODE': 'mode' }, 'JUMBLR': { 'NOTICE': 'EXPERIMENTAL TEST VERSION ONLY', From ca5d666e454f41870b236b91a1fd62423369603d Mon Sep 17 00:00:00 2001 From: petitPapillon Date: Sun, 11 Jun 2017 23:08:05 +0200 Subject: [PATCH 3/3] triggerToaster call - remove 'display' property --- react/src/components/addcoin/addcoin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/src/components/addcoin/addcoin.js b/react/src/components/addcoin/addcoin.js index 85ce5f5..c684408 100644 --- a/react/src/components/addcoin/addcoin.js +++ b/react/src/components/addcoin/addcoin.js @@ -283,7 +283,7 @@ class AddCoin extends React.Component { for (let mode of modes) { if (this.existingCoins[mode].indexOf(coin) !== -1) { const message = `${coin} ${translate('ADD_COIN.ALREADY_ADDED')} ${translate('ADD_COIN.IN')} ${mode} ${translate('ADD_COIN.MODE')}`; - Store.dispatch(triggerToaster(true, message, translate('ADD_COIN.COIN_ALREADY_ADDED'), 'error')); + Store.dispatch(triggerToaster(message, translate('ADD_COIN.COIN_ALREADY_ADDED'), 'error')); return true; } }