Skip to content

Commit 67a12f9

Browse files
committed
chore(core): use input.props.state.currency.wallets directly
Avoids destructuring mutable state which can lead to stale references.
1 parent 0bce372 commit 67a12f9

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

src/core/currency/currency-pixie.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,12 @@ export const currency: TamePixie<RootProps> = combinePixies({
264264
// response:
265265
subscriptionTimeoutId = setTimeout(() => {
266266
subscriptionTimeoutId = undefined
267-
// Refresh the state to avoid using stale data:
268-
const { wallets } = input.props.state.currency
269267
const walletIds = new Set(
270268
indexToWalletId.map(item => item.walletId)
271269
)
272270
for (const walletId of walletIds) {
273-
const wallet = wallets[walletId]
271+
// Using input.props.state.currency directly because it's mutable:
272+
const wallet = input.props.state.currency.wallets[walletId]
274273
// Skip if wallet was removed during timeout:
275274
if (wallet == null) continue
276275
const subscriptions = wallet.changeServiceSubscriptions
@@ -302,15 +301,13 @@ export const currency: TamePixie<RootProps> = combinePixies({
302301
subscriptionTimeoutId = undefined
303302
}
304303

305-
// Refresh state to avoid using stale wallet data after the await:
306-
const { wallets: freshWallets } = input.props.state.currency
307-
308304
const subscriptionUpdates: Map<string, ChangeServiceSubscription[]> =
309305
new Map()
310306
for (let i = 0; i < results.length; i++) {
311307
const result = results[i]
312308
const { walletId } = indexToWalletId[i]
313-
const wallet = freshWallets[walletId]
309+
// Using input.props.state.currency directly because it's mutable:
310+
const wallet = input.props.state.currency.wallets[walletId]
314311

315312
// Skip if wallet was removed during await:
316313
if (wallet == null) continue

0 commit comments

Comments
 (0)