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

Commit

Permalink
Fix active state reducer mutating existing state
Browse files Browse the repository at this point in the history
Summary:
This reducer was mutating existing state, which will throw since we freeze state to prevent exactly that. Fixed it by using a defensive copy.

Note that `newActiveNotifications` doesn't suffer from the same as it is freshly allocated.

See https://www.internalfb.com/intern/diffusion/FBS/browse/master/xplat/sonar/desktop/app/src/reducers/notifications.tsx?commit=29b592866b44&lines=160

Reviewed By: passy

Differential Revision: D26399200

fbshipit-source-id: 5f9f22db3de48f4f595a028faf9e9ec547641cfb
  • Loading branch information
mweststrate authored and facebook-github-bot committed Feb 11, 2021
1 parent a1194b2 commit 8d5f136
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion desktop/app/src/reducers/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function activeNotificationsReducer(
): State {
const {payload} = action;
const newActiveNotifications = [];
const newInactivatedNotifications = state.invalidatedNotifications;
const newInactivatedNotifications = state.invalidatedNotifications.slice();

const newIDs = new Set(payload.notifications.map((n: Notification) => n.id));

Expand Down

0 comments on commit 8d5f136

Please sign in to comment.