Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Feature) Update token's balance on account switch #120

Merged
merged 4 commits into from
Sep 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions old-ui/app/components/token-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ TokenList.prototype.componentDidMount = function () {
this.createFreshTokenTracker()
}

TokenList.prototype.createFreshTokenTracker = function () {
TokenList.prototype.createFreshTokenTracker = function (userAddress) {
if (this.tracker) {
// Clean up old trackers when refreshing:
this.tracker.stop()
Expand All @@ -162,9 +162,8 @@ TokenList.prototype.createFreshTokenTracker = function () {
}

if (!global.ethereumProvider) return
const { userAddress } = this.props
this.tracker = new TokenTracker({
userAddress,
userAddress: userAddress || this.props.userAddress,
provider: global.ethereumProvider,
tokens: this.props.tokens,
pollingInterval: 8000,
Expand Down Expand Up @@ -194,9 +193,12 @@ TokenList.prototype.componentWillUpdate = function (nextProps) {
const oldNet = this.props.network
const newNet = nextProps.network

if (oldNet && newNet && newNet !== oldNet) {
const oldAddress = this.props.userAddress
const newAddress = nextProps.userAddress

if (oldNet && newNet && (newNet !== oldNet || newAddress !== oldAddress)) {
this.setState({ isLoading: true })
this.createFreshTokenTracker()
this.createFreshTokenTracker(newAddress)
}
}

Expand Down