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 {
fetchPayments,
fetchInvoices,
@ -42,12 +42,22 @@ class Activity extends Component {
fetchChannels()
// 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) {
const { ticker, currentTicker, showActivityModal, network, currencyName } = this.props
if (!currencyName) {
return null
}
if (Object.prototype.hasOwnProperty.call(activity, 'block_hash')) {
// activity is an on-chain tx
return (
@ -265,7 +275,7 @@ Activity.propTypes = {
balance: PropTypes.object.isRequired,
walletProps: PropTypes.object.isRequired,
currencyName: PropTypes.string.isRequired
currencyName: PropTypes.string
}
export default injectIntl(Activity)

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

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

5
app/components/Wallet/Wallet.js

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

1
app/containers/App.js

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

Loading…
Cancel
Save