Remove unnecessary token list update (#8223)

When the token tracker is first constructed and the first balance
update is triggered, we manually serialize the tracker state and call
our update function. This is _in addition_ to the update event handler
though, so the balances get updated twice. Similarly, we also catch any
errors during this first update to handle them, but this is done via an
event as well, so is redundant.

These steps have been removed; updates and errors are now handled
solely through events. We were able to drop a check from
`updateBalances` as well to ensure the tracker is still running, as the
event cannot be emitted unless it's running.
feature/default_network_editable
Mark Stacey 5 years ago committed by GitHub
parent 0af02d5194
commit c167fbf903
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      ui/app/components/app/token-list.js

@ -73,19 +73,9 @@ class TokenList extends Component {
this.tracker.on('error', this.showError) this.tracker.on('error', this.showError)
this.tracker.updateBalances() this.tracker.updateBalances()
.then(() => {
this.updateBalances(this.tracker.serialize())
})
.catch((reason) => {
log.error(`Problem updating balances`, reason)
this.setState({ isLoading: false })
})
} }
updateBalances = function (tokens) { updateBalances = function (tokens) {
if (!this.tracker.running) {
return
}
this.setState({ tokens, isLoading: false }) this.setState({ tokens, isLoading: false })
} }

Loading…
Cancel
Save