diff --git a/react/src/actions/actions/nativeSyncInfo.js b/react/src/actions/actions/nativeSyncInfo.js index 21fcabc..783fbe5 100644 --- a/react/src/actions/actions/nativeSyncInfo.js +++ b/react/src/actions/actions/nativeSyncInfo.js @@ -18,6 +18,8 @@ export function nativeGetinfoFailureState() { // TODO: use debug.log instead export function getSyncInfoNativeKMD(skipDebug, json, skipRemote) { + let _json = json; + if (skipRemote) { return dispatch => { dispatch(getSyncInfoNativeState(Config.iguanaLessMode ? json.info : json )); @@ -44,11 +46,15 @@ export function getSyncInfoNativeKMD(skipDebug, json, skipRemote) { ) );*/ console.warn('remote kmd node fetch failed', true); - dispatch(getSyncInfoNativeState({ remoteKMDNode: null })); + _json = _json.error; + _json['remoteKMDNode'] = null; + dispatch(getSyncInfoNativeState(_json)); }) .then(response => response.json()) .then(json => { - dispatch(getSyncInfoNativeState({ remoteKMDNode: Config.iguanaLessMode ? json.info : json })); + _json = _json.error; + _json['remoteKMDNode'] = json.info; + dispatch(getSyncInfoNativeState(_json)); }) .then(function() { if (!skipDebug) { @@ -60,23 +66,34 @@ export function getSyncInfoNativeKMD(skipDebug, json, skipRemote) { } function getSyncInfoNativeState(json, coin, skipDebug, skipRemote) { - if (coin === 'KMD' && - json && - json.error && - json.error.message.indexOf('Activating best') === -1) { - return getSyncInfoNativeKMD(skipDebug, json, skipRemote); + /*if (!json.remoteKMDNode) { + json = { error: { code: -28, message: 'Activating best chain...' } }; + }*/ + + if (json.remoteKMDNode) { + return { + type: SYNCING_NATIVE_MODE, + progress: json, + } } else { - if (json && + if (coin === 'KMD' && + json && json.error && - Config.cli.default) { - return { - type: SYNCING_NATIVE_MODE, - progress: json.error, - } + json.error.message.indexOf('Activating best') > -1) { + return getSyncInfoNativeKMD(skipDebug, json, skipRemote); } else { - return { - type: SYNCING_NATIVE_MODE, - progress: json.result ? json.result : json, + if (json && + json.error && + Config.cli.default) { + return { + type: SYNCING_NATIVE_MODE, + progress: json.error, + } + } else { + return { + type: SYNCING_NATIVE_MODE, + progress: json.result ? json.result : json, + } } } } diff --git a/react/src/components/dashboard/walletsProgress/walletsProgress.js b/react/src/components/dashboard/walletsProgress/walletsProgress.js index 81efe7c..7daaf05 100644 --- a/react/src/components/dashboard/walletsProgress/walletsProgress.js +++ b/react/src/components/dashboard/walletsProgress/walletsProgress.js @@ -107,14 +107,27 @@ class WalletsProgress extends React.Component { } if (temp[i].indexOf('progress=') > -1) { currentProgress = Number(temp[i].replace('progress=', '')) * 1000; - currentProgress = currentProgress >= 100 ? 100 : currentProgress; + if (currentProgress > 100) { + currentProgress = Number(temp[i].replace('progress=', '')) * 100; + } } } - return [ - currentBestChain, - currentProgress - ]; + if (this.props.ActiveCoin.progress.remoteKMDNode && + this.props.ActiveCoin.progress.remoteKMDNode.blocks) { + const longestHeight = this.props.ActiveCoin.progress.remoteKMDNode.blocks; + + return [ + currentBestChain, + currentProgress, + longestHeight + ]; + } else { + return [ + currentBestChain, + currentProgress + ]; + } } } @@ -131,7 +144,7 @@ class WalletsProgress extends React.Component { if (_parseProgress && _parseProgress[1]) { - return SyncPercentageRender.call(this, _parseProgress[1] === 1000 ? 100 : _parseProgress[1].toFixed(2)); + return SyncPercentageRender.call(this, _parseProgress[1].toFixed(2) + '%', _parseProgress[0], _parseProgress[2] ? _parseProgress[2] : null); } else { return LoadingBlocksRender.call(this); } diff --git a/react/src/components/dashboard/walletsProgress/walletsProgress.render.js b/react/src/components/dashboard/walletsProgress/walletsProgress.render.js index c4ce931..a3d6dfe 100644 --- a/react/src/components/dashboard/walletsProgress/walletsProgress.render.js +++ b/react/src/components/dashboard/walletsProgress/walletsProgress.render.js @@ -17,7 +17,7 @@ export const SyncErrorBlocksRender = function() { ); }; -export const SyncPercentageRender = function(syncPercentage) { +export const SyncPercentageRender = function(syncPercentage, currentBlock, maxHeight) { if (this.props.ActiveCoin.rescanInProgress) { return (
); } else { + // if (this.props.ActiveCoin.progress) return (
- { syncPercentage === '100.00%' ? '100%' : syncPercentage } | { this.props.ActiveCoin.progress.blocks } / { this.props.ActiveCoin.progress.longestchain } | { translate('INDEX.CONNECTIONS') }: { this.props.ActiveCoin.progress.connections } + { syncPercentage === '100.00%' ? '100%' : syncPercentage } | { this.props.ActiveCoin.progress.blocks || currentBlock } / { this.props.ActiveCoin.progress.longestchain || maxHeight } | { translate('INDEX.CONNECTIONS') }: { this.props.ActiveCoin.progress.connections }
); } diff --git a/react/src/reducers/activeCoin.js b/react/src/reducers/activeCoin.js index 5df873d..57ee12a 100644 --- a/react/src/reducers/activeCoin.js +++ b/react/src/reducers/activeCoin.js @@ -228,8 +228,6 @@ export function ActiveCoin(state = { getinfoFetchFailures: !action.progress ? state.getinfoFetchFailures + 1 : 0, }; case DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE: - console.warn('_getinfoFetchFailures', state.getinfoFetchFailures + 1); - return { ...state, getinfoFetchFailures: state.getinfoFetchFailures + 1,