Skip to content

Commit

Permalink
Merge pull request #1202 from poanetwork/issue#1201
Browse files Browse the repository at this point in the history
(Feature) Update contribution page if account was switched in wallet
  • Loading branch information
fernandomg committed Oct 26, 2018
2 parents 0d820a3 + f9eff85 commit 284af7f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/contribute/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import { DEPLOYMENT_VALUES } from '../../utils/constants'
let promiseRetry = require('promise-retry')

const logger = logdown('TW:contribute')
const TWO_SECONDS = 2000

@inject(
'contractStore',
Expand Down Expand Up @@ -116,6 +117,17 @@ export class Contribute extends React.Component {

componentDidMount() {
this.preparePage()
setTimeout(this.fetchAccount, TWO_SECONDS)
}

fetchAccount = async () => {
const account = await getCurrentAccount()
logger.log(`Check for account has changed:`, account !== this.state.curAddr)
if (account !== this.state.curAddr) {
await this.extractContractsData()
}
// We cant use setInterval, because we dont know what the function takes in time
setTimeout(this.fetchAccount, TWO_SECONDS)
}

preparePage = async () => {
Expand Down

0 comments on commit 284af7f

Please sign in to comment.