From 1aeaafcbe3d57c4a28bfb26aa8e9ffbc7d6047e4 Mon Sep 17 00:00:00 2001 From: Yongfeng LI Date: Wed, 18 Apr 2018 13:14:51 +0800 Subject: [PATCH] improve block confirmations info --- src/features/transactions/components/List.jsx | 2 ++ src/features/transactions/components/ListItem/ListItem.jsx | 6 +++++- src/features/transactions/components/Show.jsx | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/features/transactions/components/List.jsx b/src/features/transactions/components/List.jsx index fc04cde..a076088 100644 --- a/src/features/transactions/components/List.jsx +++ b/src/features/transactions/components/List.jsx @@ -45,9 +45,11 @@ const mapStateToProps = (type, itemComponent, additionalProps = {}) => { const keysArray = Object.keys(totalItems) const totalNumberPage = Math.ceil(keysArray.length/pageSize) const startIndex = (currentPage - 1) * pageSize + const highestBlock = state.core.coreData && state.core.coreData.highestBlock const currentItems = keysArray.slice(startIndex, startIndex + pageSize).map( id => totalItems[id] ).filter(item => item != undefined) + currentItems.forEach(item => item.highest = highestBlock) return { currentPage: currentPage, diff --git a/src/features/transactions/components/ListItem/ListItem.jsx b/src/features/transactions/components/ListItem/ListItem.jsx index 61113b0..1f0e433 100644 --- a/src/features/transactions/components/ListItem/ListItem.jsx +++ b/src/features/transactions/components/ListItem/ListItem.jsx @@ -8,6 +8,7 @@ class ListItem extends React.Component { render() { const item = this.props.item const lang = this.props.lang + const confirmation = item.highest - item.blockHeight + 1 return(
@@ -15,10 +16,13 @@ class ListItem extends React.Component {
 {item.id}  - + + + { `${confirmation} block confirmation${confirmation > 1 ? 's' : ''}` } +
{lang === 'zh' ? '查看详情' : 'View details'} diff --git a/src/features/transactions/components/Show.jsx b/src/features/transactions/components/Show.jsx index e335ef8..7d55830 100644 --- a/src/features/transactions/components/Show.jsx +++ b/src/features/transactions/components/Show.jsx @@ -22,6 +22,7 @@ class Show extends BaseShow { let view if (item) { + const confirmation = this.props.highestBlock - item.blockHeight + 1 const btmInput = item.inputs.reduce((sum, input) => { if (input.type === 'spend' && input.assetAlias === 'BTM') { sum += input.amount @@ -63,7 +64,7 @@ class Show extends BaseShow { {label: 'ID', value: item.id}, {label: 'Timestamp', value: moment.unix(item.timestamp).format()}, {label: 'Block ID', value: item.blockId}, - {label: 'Block Height', value: (item.blockHeight + `(${this.props.highestBlock - item.blockHeight + 1} confirmations)`)}, + {label: 'Block Height', value: (item.blockHeight + `(${confirmation} block confirmation${confirmation > 1 ? 's' : ''})`)}, {label: 'Position', value: item.position}, {label: 'Gas', value: gas}, ]} -- 2.11.0