aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-06-23 23:00:58 +0800
committerDan Finlay <dan@danfinlay.com>2017-06-23 23:00:58 +0800
commitb04d1de44733065fe6762542eca843a7d9e3d099 (patch)
tree2086d693e02e5ef0570acb9f3b5dfe8a78e5ce65 /ui/app/components
parent97ab48ba0d5c0699b4ec0ad4bbc3d9c8805ef048 (diff)
parentf022c7c714e17faf9558839116ba90ca8082e6b1 (diff)
downloadtangerine-wallet-browser-b04d1de44733065fe6762542eca843a7d9e3d099.tar.gz
tangerine-wallet-browser-b04d1de44733065fe6762542eca843a7d9e3d099.tar.zst
tangerine-wallet-browser-b04d1de44733065fe6762542eca843a7d9e3d099.zip
Merge branch 'master' into i784-SendTokenButton
Diffstat (limited to 'ui/app/components')
-rw-r--r--ui/app/components/token-list.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/ui/app/components/token-list.js b/ui/app/components/token-list.js
index 100e596ed..d2d83de26 100644
--- a/ui/app/components/token-list.js
+++ b/ui/app/components/token-list.js
@@ -29,13 +29,18 @@ function TokenList () {
TokenList.prototype.render = function () {
const state = this.state
- const { isLoading, tokens } = state
+ const { tokens, isLoading, error } = state
const { userAddress, network } = this.props
if (isLoading) {
return this.message('Loading')
}
+ if (error) {
+ log.error(error)
+ return this.message('There was a problem loading your token balances.')
+ }
+
const tokenViews = tokens.map((tokenData) => {
tokenData.network = network
tokenData.userAddress = userAddress
@@ -114,7 +119,10 @@ TokenList.prototype.componentDidMount = function () {
TokenList.prototype.createFreshTokenTracker = function () {
if (this.tracker) {
+ // Clean up old trackers when refreshing:
this.tracker.stop()
+ this.tracker.removeListener('update', this.balanceUpdater)
+ this.tracker.removeListener('error', this.showError)
}
if (!global.ethereumProvider) return
@@ -126,9 +134,15 @@ TokenList.prototype.createFreshTokenTracker = function () {
pollingInterval: 8000,
})
- this.tracker.on('update', (tokenData) => {
- this.updateBalances(tokenData)
- })
+
+ // Set up listener instances for cleaning up
+ this.balanceUpdater = this.updateBalances.bind(this)
+ this.showError = (error) => {
+ this.setState({ error, isLoading: false })
+ }
+ this.tracker.on('update', this.balanceUpdater)
+ this.tracker.on('error', this.showError)
+
this.tracker.updateBalances()
.then(() => {
this.updateBalances(this.tracker.serialize())