diff options
author | Dan <danjm.com@gmail.com> | 2017-10-04 01:25:52 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2017-10-04 06:46:01 +0800 |
commit | ac4868170f4c61d13291389d01bf1002fe240ed4 (patch) | |
tree | d4000928e6b890d99d28b8109ad82cde7bf82fce /ui/app/components/token-list.js | |
parent | 45dbd017e65e5698db4580c77d723bface0e9b63 (diff) | |
download | tangerine-wallet-browser-ac4868170f4c61d13291389d01bf1002fe240ed4.tar.gz tangerine-wallet-browser-ac4868170f4c61d13291389d01bf1002fe240ed4.tar.zst tangerine-wallet-browser-ac4868170f4c61d13291389d01bf1002fe240ed4.zip |
Enables remove token and ensures add/remove update the list without need for refresh.
Diffstat (limited to 'ui/app/components/token-list.js')
-rw-r--r-- | ui/app/components/token-list.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ui/app/components/token-list.js b/ui/app/components/token-list.js index 0efa89c63..fb11be826 100644 --- a/ui/app/components/token-list.js +++ b/ui/app/components/token-list.js @@ -27,7 +27,6 @@ for (const address in contracts) { module.exports = connect(mapStateToProps)(TokenList) - inherits(TokenList, Component) function TokenList () { this.state = { @@ -129,15 +128,22 @@ TokenList.prototype.componentDidUpdate = function (nextProps) { const { network: oldNet, userAddress: oldAddress, + tokens, } = this.props const { network: newNet, userAddress: newAddress, + tokens: newTokens, } = nextProps - if (newNet === 'loading') return - if (!oldNet || !newNet || !oldAddress || !newAddress) return - if (oldAddress === newAddress && oldNet === newNet) return + const isLoading = newNet === 'loading' + const missingInfo = !oldNet || !newNet || !oldAddress || !newAddress + const sameUserAndNetwork = oldAddress === newAddress && oldNet === newNet + const shouldUpdateTokens = isLoading || missingInfo || sameUserAndNetwork + + const tokensLengthUnchanged = tokens.length === newTokens.length + + if (tokensLengthUnchanged && shouldUpdateTokens) return this.setState({ isLoading: true }) this.createFreshTokenTracker() |