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
Show file tree
Hide file tree
Changes from 2 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
4 changes: 3 additions & 1 deletion test/e2e/metamask.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,9 @@ describe('Metamask popup page', async function () {
await delay(500)
await driver.findElement(By.css(screens.addToken.fieldTokenSymbol)).sendKeys(tokenName)
await delay(500)
await driver.findElement(By.css(screens.addToken.fieldDecimals)).sendKeys(tokenDecimals)
const decimalsField = await driver.findElement(By.css(screens.addToken.fieldDecimals))
await decimalsField.clear()
await decimalsField.sendKeys(tokenDecimals)
const buttonAdd = await waitUntilShowUp(By.css(screens.addToken.buttonAdd))
await buttonAdd.click()
return true
Expand Down