From 8cd975b706d9c510088b93fecd6638d3b78833c1 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Wed, 13 Sep 2017 17:59:20 +0300 Subject: [PATCH] err no longestchain, err no blocks alt. wording --- .../walletsProgress/walletsProgress.js | 34 ++++++++++++++----- .../walletsProgress/walletsProgress.render.js | 32 +++++++++-------- react/src/translate/en.js | 3 +- 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/react/src/components/dashboard/walletsProgress/walletsProgress.js b/react/src/components/dashboard/walletsProgress/walletsProgress.js index d70c8fb..3887d0f 100644 --- a/react/src/components/dashboard/walletsProgress/walletsProgress.js +++ b/react/src/components/dashboard/walletsProgress/walletsProgress.js @@ -2,7 +2,6 @@ import React from 'react'; import { connect } from 'react-redux'; import { translate } from '../../../translate/translate'; import { - SyncErrorLongestChainRender, SyncErrorBlocksRender, SyncPercentageRender, LoadingBlocksRender, @@ -15,9 +14,33 @@ import { class WalletsProgress extends React.Component { constructor() { super(); + this.state = { + prevProgress: {}, + }; this.isFullySynced = this.isFullySynced.bind(this); } + componentWillReceiveProps(props) { + if (props.ActiveCoin && + props.ActiveCoin.progress && + Number(props.ActiveCoin.progress.longestchain) === 0) { + let _progress = props.ActiveCoin.progress; + + if (this.state.prevProgress && + this.state.prevProgress.longestchain && + Number(this.state.prevProgress.longestchain) > 0) { + _progress.longestchain = this.state.prevProgress.longestchain; + } + this.setState(Object.assign({}, this.state, { + prevProgress: _progress, + })); + } else { + this.setState(Object.assign({}, this.state, { + prevProgress: props.ActiveCoin.progress, + })); + } + } + isFullySynced() { const _progress = this.props.ActiveCoin.progress; @@ -96,6 +119,7 @@ class WalletsProgress extends React.Component { renderSyncPercentagePlaceholder() { const _progress = this.props.ActiveCoin.progress; + console.warn('renderSyncPercentagePlaceholder', _progress); // activating best chain if (_progress && @@ -112,12 +136,6 @@ class WalletsProgress extends React.Component { } } - if (_progress && - _progress.blocks > 0 && - _progress.longestchain === 0) { - return SyncErrorLongestChainRender.call(this); - } - if (_progress && _progress.blocks === 0) { return SyncErrorBlocksRender.call(this); @@ -125,7 +143,7 @@ class WalletsProgress extends React.Component { if (_progress && _progress.blocks) { - const syncPercentage = (parseFloat(parseInt(_progress.blocks, 10) * 100 / parseInt(_progress.longestchain, 10)).toFixed(2) + '%').replace('NaN', 0); + const syncPercentage = (parseFloat(parseInt(_progress.blocks, 10) * 100 / parseInt(Number(_progress.longestchain) || Number(this.state.prevProgress.longestchain), 10)).toFixed(2) + '%').replace('NaN', 0); return SyncPercentageRender.call(this, syncPercentage === 1000 ? 100 : syncPercentage); } diff --git a/react/src/components/dashboard/walletsProgress/walletsProgress.render.js b/react/src/components/dashboard/walletsProgress/walletsProgress.render.js index 4ea4f60..14e5f9c 100644 --- a/react/src/components/dashboard/walletsProgress/walletsProgress.render.js +++ b/react/src/components/dashboard/walletsProgress/walletsProgress.render.js @@ -1,14 +1,6 @@ import React from 'react'; import { translate } from '../../../translate/translate'; -export const SyncErrorLongestChainRender = function() { - return ( -
- { translate('INDEX.SYNC_ERR_LONGESTCHAIN') } -
- ); -}; - export const SyncErrorBlocksRender = function() { return (
@@ -27,13 +19,23 @@ export const SyncPercentageRender = function(syncPercentage) {
); } else { - return ( -
- { syncPercentage } | { this.props.ActiveCoin.progress.blocks } / { this.props.ActiveCoin.progress.longestchain } | { translate('INDEX.CONNECTIONS') }: { this.props.ActiveCoin.progress.connections } -
- ); + if (syncPercentage === 'Infinity%') { + return ( +
+ Blocks: { this.props.ActiveCoin.progress.blocks } | { translate('INDEX.CONNECTIONS') }: { this.props.ActiveCoin.progress.connections } +
+ ); + } else { + return ( +
+ { syncPercentage === '100.00%' ? '100%' : syncPercentage } | { this.props.ActiveCoin.progress.blocks } / { this.props.ActiveCoin.progress.longestchain } | { translate('INDEX.CONNECTIONS') }: { this.props.ActiveCoin.progress.connections } +
+ ); + } } }; diff --git a/react/src/translate/en.js b/react/src/translate/en.js index e667d3d..91d31c3 100644 --- a/react/src/translate/en.js +++ b/react/src/translate/en.js @@ -121,8 +121,7 @@ export const _lang = { 'PREVIOUS': 'Previous', 'NEXT': 'Next', 'ENTRIES_SM': 'entries', - 'SYNC_ERR_LONGESTCHAIN': 'Unable to get current sync progress. Err: no longestchain param in response', - 'SYNC_ERR_BLOCKS': 'Unable to get current sync progress. Err: no blocks param in response', + 'SYNC_ERR_BLOCKS': 'Connecting to peers...', 'COIN_IS_BUSY': 'Coin is busy processing', 'REFRESHING_BASILISK_NET': 'Refreshing Basilisk Network Connections', 'SELECT_A_COIN': 'Select Coin to add to Agama Wallet',