WA-232 Avoid re-renderings when updating safe balances

This commit is contained in:
apanizo 2018-06-29 15:41:29 +02:00
parent 06e8b0153e
commit 667fae279d
2 changed files with 8 additions and 6 deletions

View File

@ -54,11 +54,7 @@ const BalanceComponent = openHoc(({
<ListItemIcon>
<Img src={balance.get('logoUrl')} height={30} alt={name} />
</ListItemIcon>
<ListItemText
cut
primary={name}
secondary={`${balance.get('funds')} ${symbol}`}
/>
<ListItemText primary={name} secondary={`${balance.get('funds')} ${symbol}`} />
</ListItem>
)
})}

View File

@ -10,5 +10,11 @@ export type State = Map<string, Map<string, Balance>>
export default handleActions({
[ADD_BALANCES]: (state: State, action: ActionType<typeof addBalances>): State =>
state.set(action.payload.safeAddress, action.payload.balances),
state.update(action.payload.safeAddress, (prevSafe: Map<string, Balance>) => {
if (!prevSafe) {
return action.payload.balances
}
return prevSafe.equals(action.payload.balances) ? prevSafe : action.payload.balances
}),
}, Map())