mirror of
https://github.com/status-im/safe-react.git
synced 2025-02-25 16:05:25 +00:00
WA-232 Improving speed
This commit is contained in:
parent
c9316686aa
commit
a64a6a0768
@ -41,12 +41,14 @@ const BalanceComponent = openHoc(({
|
|||||||
<AccountBalance />
|
<AccountBalance />
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<ListItemText primary="Balance" secondary="List of different token balances" />
|
<ListItemText primary="Balance" secondary="List of different token balances" />
|
||||||
<ListItemIcon>
|
{ balances.count() > 0 &&
|
||||||
{open
|
<ListItemIcon>
|
||||||
? <IconButton disableRipple><ExpandLess /></IconButton>
|
{open
|
||||||
: <IconButton disableRipple><ExpandMore /></IconButton>
|
? <IconButton disableRipple><ExpandLess /></IconButton>
|
||||||
}
|
: <IconButton disableRipple><ExpandMore /></IconButton>
|
||||||
</ListItemIcon>
|
}
|
||||||
|
</ListItemIcon>
|
||||||
|
}
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<Collapse in={open} timeout="auto">
|
<Collapse in={open} timeout="auto">
|
||||||
<List component="div" disablePadding>
|
<List component="div" disablePadding>
|
||||||
|
@ -21,7 +21,7 @@ class SafeView extends React.PureComponent<Props> {
|
|||||||
const safeAddress = safe.get('address')
|
const safeAddress = safe.get('address')
|
||||||
fetchBalances(safeAddress)
|
fetchBalances(safeAddress)
|
||||||
fetchSafe(safe)
|
fetchSafe(safe)
|
||||||
}, 1500)
|
}, 15000)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
|
@ -9,7 +9,6 @@ import { makeBalance, type Balance, type BalanceProps } from '~/routes/safe/stor
|
|||||||
import logo from '~/assets/icons/icon_etherTokens.svg'
|
import logo from '~/assets/icons/icon_etherTokens.svg'
|
||||||
import addBalances from './addBalances'
|
import addBalances from './addBalances'
|
||||||
|
|
||||||
|
|
||||||
export const getStandardTokenContract = async () => {
|
export const getStandardTokenContract = async () => {
|
||||||
const web3 = getWeb3()
|
const web3 = getWeb3()
|
||||||
const erc20Token = await contract(StandardToken)
|
const erc20Token = await contract(StandardToken)
|
||||||
@ -52,15 +51,15 @@ export const fetchBalances = (safeAddress: string) => async (dispatch: ReduxDisp
|
|||||||
}
|
}
|
||||||
|
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
const balancesRecords = await Promise.all(json.map(async (item: BalanceProps) => {
|
return Promise.all(json.map(async (item: BalanceProps) => {
|
||||||
const funds = await calculateBalanceOf(item.address, safeAddress, item.decimals)
|
const funds = await calculateBalanceOf(item.address, safeAddress, item.decimals)
|
||||||
return makeBalance({ ...item, funds })
|
return makeBalance({ ...item, funds })
|
||||||
}))
|
})).then((balancesRecords) => {
|
||||||
|
const balances: Map<string, Balance> = Map().withMutations((map) => {
|
||||||
|
balancesRecords.forEach(record => map.set(record.get('symbol'), record))
|
||||||
|
map.set('ETH', ethBalance)
|
||||||
|
})
|
||||||
|
|
||||||
const balances: Map<string, Balance> = Map().withMutations((map) => {
|
return dispatch(addBalances(safeAddress, balances))
|
||||||
balancesRecords.forEach(record => map.set(record.get('symbol'), record))
|
|
||||||
map.set('ETH', ethBalance)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return dispatch(addBalances(safeAddress, balances))
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user