Skip to content

Commit 0ad9cff

Browse files
committed
Keep the existing balanceMap when a balance report is unchanged
Engines re-report balances they already reported, and each report used to allocate a fresh Map. An unchanged balance now keeps the existing Map, so memoized reducers, the wallet cache saver, and yaob's === diffing see no phantom update.
1 parent c09ac2c commit 0ad9cff

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/core/currency/wallet/currency-wallet-reducer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ const currencyWalletInner = buildReducer<
361361
balanceMap(state = new Map(), action): Map<EdgeTokenId, string> {
362362
if (action.type === 'CURRENCY_ENGINE_CHANGED_BALANCE') {
363363
const { balance, tokenId } = action.payload
364+
// Keep the existing Map when nothing changed, so downstream
365+
// reference checks (memoized reducers, the cache saver, yaob
366+
// diffing) see no phantom update:
367+
if (state.get(tokenId) === balance) return state
364368
const out = new Map(state)
365369
out.set(tokenId, balance)
366370
return out

0 commit comments

Comments
 (0)