1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

refetch balance (#357)

This commit is contained in:
mihaisc 2021-01-29 16:21:34 +02:00 committed by GitHub
parent a760935564
commit ab609b93c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import { getOceanConfig } from './wrapRootElement'
import { Logger } from '@oceanprotocol/lib' import { Logger } from '@oceanprotocol/lib'
import { ConfigHelperConfig } from '@oceanprotocol/lib/dist/node/utils/ConfigHelper' import { ConfigHelperConfig } from '@oceanprotocol/lib/dist/node/utils/ConfigHelper'
const refreshInterval = 5000 // 5 sec.
export function NetworkMonitor(): ReactElement { export function NetworkMonitor(): ReactElement {
const { const {
connect, connect,
@ -11,7 +12,8 @@ export function NetworkMonitor(): ReactElement {
web3, web3,
networkId, networkId,
config, config,
accountId refreshBalance,
account
} = useOcean() } = useOcean()
async function handleNetworkChanged(chainId: string | number) { async function handleNetworkChanged(chainId: string | number) {
@ -37,7 +39,16 @@ export function NetworkMonitor(): ReactElement {
Logger.error(error.message) Logger.error(error.message)
} }
} }
useEffect(() => {
if (!account) return
refreshBalance()
const balanceInterval = setInterval(() => refreshBalance(), refreshInterval)
return () => {
clearInterval(balanceInterval)
}
}, [networkId, account])
// Re-connect on mount when network is different from user network. // Re-connect on mount when network is different from user network.
// Bit nasty to just overwrite the initialConfig passed to OceanProvider // Bit nasty to just overwrite the initialConfig passed to OceanProvider
// while it's connecting to that, but YOLO. // while it's connecting to that, but YOLO.

View File

@ -89,7 +89,7 @@ export default async function get3BoxProfile(
) )
return return
Logger.log(`3Box profile found for ${accountId}`, response.data) // Logger.log(`3Box profile found for ${accountId}`, response.data)
const profile = transformResponse(response.data) const profile = transformResponse(response.data)
return profile return profile
// eslint-disable-next-line no-empty // eslint-disable-next-line no-empty