WA-232 Avoid re-renderings when updating safe balances
This commit is contained in:
parent
06e8b0153e
commit
667fae279d
|
@ -54,11 +54,7 @@ const BalanceComponent = openHoc(({
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<Img src={balance.get('logoUrl')} height={30} alt={name} />
|
<Img src={balance.get('logoUrl')} height={30} alt={name} />
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText
|
<ListItemText primary={name} secondary={`${balance.get('funds')} ${symbol}`} />
|
||||||
cut
|
|
||||||
primary={name}
|
|
||||||
secondary={`${balance.get('funds')} ${symbol}`}
|
|
||||||
/>
|
|
||||||
</ListItem>
|
</ListItem>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -10,5 +10,11 @@ export type State = Map<string, Map<string, Balance>>
|
||||||
|
|
||||||
export default handleActions({
|
export default handleActions({
|
||||||
[ADD_BALANCES]: (state: State, action: ActionType<typeof addBalances>): State =>
|
[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())
|
}, Map())
|
||||||
|
|
Loading…
Reference in New Issue