mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
fix rerender during consuming flow
This commit is contained in:
parent
745969f686
commit
5f1cc2cb1d
@ -161,10 +161,7 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
|||||||
// Get accounts
|
// Get accounts
|
||||||
await this.fetchAccounts()
|
await this.fetchAccounts()
|
||||||
|
|
||||||
// Set proper network names now that we have Ocean
|
this.setState({ isLoading: false, message: '' })
|
||||||
await this.fetchNetwork()
|
|
||||||
|
|
||||||
this.setState({ isLoading: false })
|
|
||||||
}
|
}
|
||||||
// Non-dapp browsers
|
// Non-dapp browsers
|
||||||
else {
|
else {
|
||||||
@ -189,15 +186,13 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
|||||||
let accounts
|
let accounts
|
||||||
|
|
||||||
// Modern dapp browsers
|
// Modern dapp browsers
|
||||||
if (window.ethereum) {
|
if (window.ethereum && !isLogged && isNile) {
|
||||||
if (!isLogged && isNile) {
|
// simply set to empty, and have user click a button somewhere
|
||||||
// simply set to empty, and have user click a button somewhere
|
// to initiate account unlocking
|
||||||
// to initiate account unlocking
|
accounts = []
|
||||||
accounts = []
|
|
||||||
|
|
||||||
// alternatively, automatically prompt for account unlocking
|
// alternatively, automatically prompt for account unlocking
|
||||||
// await this.unlockAccounts()
|
// await this.unlockAccounts()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
accounts = await ocean.accounts.list()
|
accounts = await ocean.accounts.list()
|
||||||
@ -211,23 +206,23 @@ export default class UserProvider extends PureComponent<{}, UserProviderState> {
|
|||||||
isLogged: true,
|
isLogged: true,
|
||||||
requestFromFaucet: () => requestFromFaucet(account)
|
requestFromFaucet: () => requestFromFaucet(account)
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
const balance = await accounts[0].getBalance()
|
await this.fetchBalance(accounts[0])
|
||||||
|
|
||||||
if (
|
|
||||||
balance.eth !== this.state.balance.eth ||
|
|
||||||
balance.ocn !== this.state.balance.ocn
|
|
||||||
) {
|
|
||||||
this.setState({ balance })
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
isLogged !== false &&
|
!isLogged && this.setState({ isLogged: false, account: '' })
|
||||||
this.setState({ isLogged: false, account: '' })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fetchBalance = async (account: any) => {
|
||||||
|
const balance = await account.getBalance()
|
||||||
|
const { eth, ocn } = balance
|
||||||
|
if (eth !== this.state.balance.eth || ocn !== this.state.balance.ocn) {
|
||||||
|
this.setState({ balance: { eth, ocn } })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fetchNetwork = async () => {
|
private fetchNetwork = async () => {
|
||||||
const { ocean, isWeb3 } = this.state
|
const { ocean, isWeb3 } = this.state
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user