From 0116ea9b95c5a9ab35d23e814a1783ef2bc11c25 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Thu, 5 Jul 2018 10:24:01 -0230 Subject: Remove TokenTracker listeners when unmounting component --- ui/app/components/token-balance.js | 2 ++ ui/app/components/token-list.js | 2 ++ 2 files changed, 4 insertions(+) (limited to 'ui') diff --git a/ui/app/components/token-balance.js b/ui/app/components/token-balance.js index df3bd59bb..5464294ce 100644 --- a/ui/app/components/token-balance.js +++ b/ui/app/components/token-balance.js @@ -110,5 +110,7 @@ TokenBalance.prototype.updateBalance = function (tokens = []) { TokenBalance.prototype.componentWillUnmount = function () { if (!this.tracker) return this.tracker.stop() + this.tracker.removeListener('update', this.balanceUpdater) + this.tracker.removeListener('error', this.showError) } diff --git a/ui/app/components/token-list.js b/ui/app/components/token-list.js index 4189cf801..89434f213 100644 --- a/ui/app/components/token-list.js +++ b/ui/app/components/token-list.js @@ -164,6 +164,8 @@ TokenList.prototype.updateBalances = function (tokens) { TokenList.prototype.componentWillUnmount = function () { if (!this.tracker) return this.tracker.stop() + this.tracker.removeListener('update', this.balanceUpdater) + this.tracker.removeListener('error', this.showError) } // function uniqueMergeTokens (tokensA, tokensB = []) { -- cgit v1.2.3 From 783559f94ef7370d2fef88327c500fbe826ac0b0 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Thu, 5 Jul 2018 10:34:16 -0230 Subject: Don't update token balances after tracker is stopped --- ui/app/components/token-balance.js | 4 ++++ ui/app/components/token-list.js | 3 +++ ui/app/helpers/with-token-tracker.js | 3 +++ 3 files changed, 10 insertions(+) (limited to 'ui') diff --git a/ui/app/components/token-balance.js b/ui/app/components/token-balance.js index 5464294ce..99ca7335c 100644 --- a/ui/app/components/token-balance.js +++ b/ui/app/components/token-balance.js @@ -98,6 +98,10 @@ TokenBalance.prototype.componentDidUpdate = function (nextProps) { } TokenBalance.prototype.updateBalance = function (tokens = []) { + if (!this.tracker.running) { + return + } + const [{ string, symbol }] = tokens this.setState({ diff --git a/ui/app/components/token-list.js b/ui/app/components/token-list.js index 89434f213..42351cf89 100644 --- a/ui/app/components/token-list.js +++ b/ui/app/components/token-list.js @@ -158,6 +158,9 @@ TokenList.prototype.componentDidUpdate = function (nextProps) { } TokenList.prototype.updateBalances = function (tokens) { + if (!this.tracker.running) { + return + } this.setState({ tokens, isLoading: false }) } diff --git a/ui/app/helpers/with-token-tracker.js b/ui/app/helpers/with-token-tracker.js index e24517c18..8608b15f4 100644 --- a/ui/app/helpers/with-token-tracker.js +++ b/ui/app/helpers/with-token-tracker.js @@ -75,6 +75,9 @@ const withTokenTracker = WrappedComponent => { } updateBalance (tokens = []) { + if (!this.tracker.running) { + return + } const [{ string, symbol }] = tokens this.setState({ string, symbol, error: null }) } -- cgit v1.2.3