Browse Source

fix(wallet): determine currency before display

Ensure that the wallet currency has been determined prior to displaying
the wallet components.
renovate/lint-staged-8.x
Tom Kirkpatrick 6 years ago
parent
commit
2424ee14b5
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 16
      app/components/Activity/Activity.js
  2. 6
      app/components/Contacts/Network/Network.js
  3. 5
      app/components/Wallet/Wallet.js
  4. 1
      app/containers/App.js

16
app/components/Activity/Activity.js

@ -26,7 +26,7 @@ class Activity extends Component {
} }
} }
componentWillMount() { componentDidMount() {
const { const {
fetchPayments, fetchPayments,
fetchInvoices, fetchInvoices,
@ -42,12 +42,22 @@ class Activity extends Component {
fetchChannels() fetchChannels()
// HACK: wait 10 seconds and fetch channels again, allowing the node to establish connections with the remote party // HACK: wait 10 seconds and fetch channels again, allowing the node to establish connections with the remote party
setTimeout(() => fetchChannels(), 10000) const timer = setTimeout(() => fetchChannels(), 10000)
this.setState({ timer })
}
componentWillUnmount() {
const { timer } = this.state
clearInterval(timer)
} }
renderActivity(activity) { renderActivity(activity) {
const { ticker, currentTicker, showActivityModal, network, currencyName } = this.props const { ticker, currentTicker, showActivityModal, network, currencyName } = this.props
if (!currencyName) {
return null
}
if (Object.prototype.hasOwnProperty.call(activity, 'block_hash')) { if (Object.prototype.hasOwnProperty.call(activity, 'block_hash')) {
// activity is an on-chain tx // activity is an on-chain tx
return ( return (
@ -265,7 +275,7 @@ Activity.propTypes = {
balance: PropTypes.object.isRequired, balance: PropTypes.object.isRequired,
walletProps: PropTypes.object.isRequired, walletProps: PropTypes.object.isRequired,
currencyName: PropTypes.string.isRequired currencyName: PropTypes.string
} }
export default injectIntl(Activity) export default injectIntl(Activity)

6
app/components/Contacts/Network/Network.js

@ -65,6 +65,10 @@ class Network extends Component {
intl intl
} = this.props } = this.props
if (!currencyName) {
return null
}
const refreshClicked = () => { const refreshClicked = () => {
// turn the spinner on // turn the spinner on
this.setState({ refreshing: true }) this.setState({ refreshing: true })
@ -406,7 +410,7 @@ Network.propTypes = {
setSelectedChannel: PropTypes.func.isRequired, setSelectedChannel: PropTypes.func.isRequired,
closeChannel: PropTypes.func.isRequired, closeChannel: PropTypes.func.isRequired,
currencyName: PropTypes.string.isRequired currencyName: PropTypes.string
} }
export default injectIntl(Network) export default injectIntl(Network)

5
app/components/Wallet/Wallet.js

@ -33,6 +33,10 @@ const Wallet = ({
paymentTimeout, paymentTimeout,
theme theme
}) => { }) => {
if (!ticker.currency) {
return null
}
const fiatAmount = btc.satoshisToFiat( const fiatAmount = btc.satoshisToFiat(
parseInt(balance.walletBalance, 10) + parseInt(balance.channelBalance, 10), parseInt(balance.walletBalance, 10) + parseInt(balance.channelBalance, 10),
currentTicker[ticker.fiatTicker] currentTicker[ticker.fiatTicker]
@ -175,7 +179,6 @@ Wallet.propTypes = {
successTransactionScreen: PropTypes.object.isRequired, successTransactionScreen: PropTypes.object.isRequired,
settingsProps: PropTypes.object.isRequired, settingsProps: PropTypes.object.isRequired,
currencyFilters: PropTypes.array.isRequired, currencyFilters: PropTypes.array.isRequired,
currencyName: PropTypes.string.isRequired,
paymentTimeout: PropTypes.number.isRequired, paymentTimeout: PropTypes.number.isRequired,
setCurrency: PropTypes.func.isRequired setCurrency: PropTypes.func.isRequired
} }

1
app/containers/App.js

@ -102,6 +102,7 @@ const mapStateToProps = state => ({
isLoading: isLoading:
infoSelectors.infoLoading(state) || infoSelectors.infoLoading(state) ||
tickerSelectors.tickerLoading(state) || tickerSelectors.tickerLoading(state) ||
!tickerSelectors.currencyName(state) ||
state.balance.channelBalance === null || state.balance.channelBalance === null ||
state.balance.walletBalance === null, state.balance.walletBalance === null,

Loading…
Cancel
Save