Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(state): do not mutate redux state
Browse files Browse the repository at this point in the history
Using redux-immutable-state-invariant I detected several places where we
were mutating the redux state directly, which should never happen.
Update the code to ensure that we do not mutate the redux state.

Fix #1120
  • Loading branch information
mrfelton committed Dec 19, 2018
1 parent 2bb7c79 commit e5ee37d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
14 changes: 9 additions & 5 deletions app/reducers/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ const ACTION_HANDLERS = {
if (item.paymentRequest !== paymentRequest) {
return item
}
item.status = 'successful'
return item
return {
...item,
status: 'successful'
}
})
}
},
Expand All @@ -149,9 +151,11 @@ const ACTION_HANDLERS = {
if (item.paymentRequest !== paymentRequest) {
return item
}
item.status = 'failed'
item.error = error
return item
return {
...item,
status: 'failed',
error
}
})
}
},
Expand Down
8 changes: 4 additions & 4 deletions app/reducers/ticker.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ tickerSelectors.currencyFilters = createSelector(
if (!crypto || !network) {
return []
}
return currencyFilters[crypto].map(item => {
item.name = `${network.unitPrefix}${item.name}`
return item
})
return currencyFilters[crypto].map(item => ({
...item,
name: `${network.unitPrefix}${item.name}`
}))
}
)

Expand Down
14 changes: 9 additions & 5 deletions app/reducers/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,10 @@ const ACTION_HANDLERS = {
if (item.addr !== addr) {
return item
}
item.status = 'successful'
return item
return {
...item,
status: 'successful'
}
})
}
},
Expand All @@ -199,9 +201,11 @@ const ACTION_HANDLERS = {
if (item.addr !== addr) {
return item
}
item.status = 'failed'
item.error = error
return item
return {
...item,
status: 'failed',
error
}
})
}
},
Expand Down

0 comments on commit e5ee37d

Please sign in to comment.