diff --git a/app/ducks/names.js b/app/ducks/names.js index 09fbd9e8b..96f961928 100644 --- a/app/ducks/names.js +++ b/app/ducks/names.js @@ -32,11 +32,11 @@ export const DROPDOWN_TYPES = [ {label: RECORD_TYPE.TXT}, ]; -export const fetchName = name => async (dispatch, getState) => { +export const fetchName = (name, force) => async (dispatch, getState) => { const {names} = getState(); const existing = names[name]; - if (existing && existing.info) { + if (!force && existing && existing.info) { return; } diff --git a/app/pages/YourBids/BidStatus.js b/app/pages/YourBids/BidStatus.js index 2feea3536..fe20e3762 100644 --- a/app/pages/YourBids/BidStatus.js +++ b/app/pages/YourBids/BidStatus.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { withRouter } from 'react-router'; import { connect } from 'react-redux'; +import throttle from 'lodash.throttle'; import { isReveal, isClosed, @@ -18,6 +19,7 @@ class BidStatus extends Component { static propTypes = { name: PropTypes.string.isRequired, domain: PropTypes.object, + height: PropTypes.number.isRequired, address: PropTypes.string.isRequired, fetchName: PropTypes.func.isRequired, }; @@ -25,11 +27,21 @@ class BidStatus extends Component { static contextType = I18nContext; componentDidMount() { - if (!this.props.domain) { - this.props.fetchName(); + this.fetchName(); + } + + componentDidUpdate(prevProps, prevState) { + if (this.props.height !== prevProps.height) { + this.fetchName(); } } + fetchName = throttle(() => { + if (this.props.name) { + this.props.fetchName(); + } + }, 10*1000, {leading: true, trailing: true}); // 10 seconds + isSold = () => isClosed(this.props.domain); isReveal = () => isReveal(this.props.domain); isOwned = () => { @@ -148,11 +160,12 @@ export default withRouter( const name = state.names[ownProps.name]; return { domain: name, + height: state.node.chain.height, address: state.wallet.receiveAddress, }; }, (dispatch, ownProps) => ({ - fetchName: () => dispatch(namesActions.fetchName(ownProps.name)), + fetchName: () => dispatch(namesActions.fetchName(ownProps.name, true)), }), )(BidStatus) );