add countersFetched flag

pull/2787/head
Ayrat Badykov 5 years ago
parent 4586ec1cca
commit e45d1f8d7b
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 10
      apps/block_scout_web/assets/js/pages/address.js

@ -18,7 +18,8 @@ export const initialState = {
balanceCard: null,
fetchedCoinBalanceBlockNumber: null,
transactionCount: null,
validationCount: null
validationCount: null,
countersFetched: false
}
export function reducer (state = initialState, action) {
@ -37,7 +38,8 @@ export function reducer (state = initialState, action) {
case 'COUNTERS_FETCHED': {
return Object.assign({}, state, {
transactionCount: action.transactionCount,
validationCount: action.validationCount
validationCount: action.validationCount,
countersFetched: true
})
}
case 'RECEIVED_NEW_BLOCK': {
@ -87,7 +89,7 @@ const elements = {
return { transactionCount: numeral($el.text()).value() }
},
render ($el, state, oldState) {
if (state.transactionCount) {
if (state.countersFetched && state.transactionCount) {
if (oldState.transactionCount === state.transactionCount) return
$el.empty().append('>= ' + numeral(state.transactionCount).format() + ' Transactions')
$el.show()
@ -110,7 +112,7 @@ const elements = {
return { validationCount: numeral($el.text()).value() }
},
render ($el, state, oldState) {
if (state.validationCount) {
if (state.countersFetched && state.validationCount) {
if (oldState.validationCount === state.validationCount) return
$el.empty().append(numeral(state.validationCount).format() + ' Blocks Validated')
$el.show()

Loading…
Cancel
Save