From ca1bbe8ee308821b486772f6d785c3b343e830f7 Mon Sep 17 00:00:00 2001 From: Zhiting Lin Date: Mon, 10 Dec 2018 14:28:47 +0800 Subject: [PATCH] add the auto refresh for the list-transaction page. --- src/features/core/reducers.js | 5 ++++- src/features/shared/components/BaseList/BaseList.jsx | 6 +++++- src/features/transactions/components/List.jsx | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/features/core/reducers.js b/src/features/core/reducers.js index 99e8f20..bf844b8 100644 --- a/src/features/core/reducers.js +++ b/src/features/core/reducers.js @@ -47,7 +47,9 @@ export const reset = (state, action) => export const httpOk = (state, action) => buildConfigReducer('isHttpOk', state, false, action) export const blockHeight = (state, action) => - coreConfigReducer('blockHeight', state, 0, action) + coreConfigReducer('highestBlock', state, 0, action) +export const currentBlockHeight = (state, action) => + coreConfigReducer('currentBlock', state, 0, action) export const generatorBlockHeight = (state, action) => { if (action.type == 'UPDATE_CORE_INFO') { if (action.param.generatorBlockHeight == 0) return '???' @@ -265,6 +267,7 @@ export default combineReducers({ configuredAt, coreType, coreData, + currentBlockHeight, generator, generatorAccessToken, generatorBlockHeight, diff --git a/src/features/shared/components/BaseList/BaseList.jsx b/src/features/shared/components/BaseList/BaseList.jsx index 7a603eb..e0216ca 100644 --- a/src/features/shared/components/BaseList/BaseList.jsx +++ b/src/features/shared/components/BaseList/BaseList.jsx @@ -7,6 +7,7 @@ import componentClassNames from 'utility/componentClassNames' import { PageContent, PageTitle, Pagination } from '../' import EmptyList from './EmptyList' import {withNamespaces} from 'react-i18next' +import {currentBlockHeight} from '../../../core/reducers' class ItemList extends React.Component { render() { @@ -87,8 +88,9 @@ export const mapStateToProps = (type, itemComponent, additionalProps = {}) => (s const paginationArray =[ 'unspent', 'transaction' ] let items = Object.assign({}, state[type].items) - const highestBlock = state.core.coreData && state.core.coreData.highestBlock + const highestBlock = state.core && state.core.highestBlock const count = (type === 'unspent')? UTXOpageSize: pageSize + const currentBlock = state.core.currentBlockHeight const currentPage = paginationArray.includes(type) && Math.max(parseInt(ownProps.location.query.page) || 1, 1) @@ -113,6 +115,8 @@ export const mapStateToProps = (type, itemComponent, additionalProps = {}) => (s loadedOnce: state[type].queries.loadedOnce, type: type, + currentBlock:currentBlock, + isLastPage: isLastPage, currentPage: currentPage, diff --git a/src/features/transactions/components/List.jsx b/src/features/transactions/components/List.jsx index 0c69ee8..97287cb 100644 --- a/src/features/transactions/components/List.jsx +++ b/src/features/transactions/components/List.jsx @@ -1,5 +1,5 @@ import React from 'react' -import { BaseList, Pagination } from 'features/shared/components' +import { BaseList } from 'features/shared/components' import { pageSize} from 'utility/environment' import ListItem from './ListItem/ListItem' import actions from 'actions' @@ -8,9 +8,9 @@ const type = 'transaction' class List extends React.Component { componentWillReceiveProps(nextProps) { - if (nextProps.blockHeight != this.props.blockHeight) { + if (nextProps.currentBlock != this.props.currentBlock) { if (nextProps.currentPage == 1) { - this.props.getLatest(nextProps.currentFilter) + this.props.getLatest('') } } } @@ -26,7 +26,7 @@ export default BaseList.connect( }), (dispatch) => ({ ...BaseList.mapDispatchToProps(type)(dispatch), - getLatest: (query) => dispatch(actions.transaction.fetchPage(query, 1, { refresh: true })), + getLatest: (query) => dispatch(actions.transaction.fetchPage(query, 1, { refresh: true, pageSize: pageSize })), }), List ) -- 2.11.0