Skip to content
Snippets Groups Projects
Unverified Commit 252ef762 authored by Jack Reed's avatar Jack Reed Committed by GitHub
Browse files

Merge pull request #3241 from ProjectMirador/3240-merge-nonrecursive

Avoid lodash-merge, which is recursive and can lead to surprises
parents f705d12d 1ccb297b
No related branches found
No related tags found
No related merge requests found
import omit from 'lodash/omit';
import set from 'lodash/fp/set';
import update from 'lodash/fp/update';
import merge from 'lodash/fp/merge';
import ActionTypes from '../actions/action-types';
/** */
......@@ -31,14 +30,14 @@ export function companionWindowsReducer(state = {}, action) {
return object;
}, {});
case ActionTypes.UPDATE_COMPANION_WINDOW:
return update([action.id], orig => merge(orig, action.payload), state);
return update([action.id], orig => ({ ...(orig || {}), ...action.payload }), state);
case ActionTypes.REMOVE_COMPANION_WINDOW:
return omit(state, action.id);
case ActionTypes.IMPORT_MIRADOR_STATE:
return action.state.companionWindows || [];
case ActionTypes.TOGGLE_TOC_NODE:
return update([action.id, 'tocNodes'], orig => merge(orig || {}, action.payload), state);
return update([action.id, 'tocNodes'], orig => ({ ...(orig || {}), ...action.payload }), state);
default:
return state;
}
......
import update from 'lodash/fp/update';
import omit from 'lodash/omit';
import merge from 'lodash/fp/merge';
import ActionTypes from '../actions/action-types';
/**
......@@ -17,7 +16,7 @@ export const elasticLayoutReducer = (state = {}, action) => {
};
case ActionTypes.UPDATE_ELASTIC_WINDOW_LAYOUT:
return update([action.windowId], orig => merge(orig, action.payload), state);
return update([action.windowId], orig => ({ ...(orig || {}), ...action.payload }), state);
case ActionTypes.REMOVE_WINDOW:
return omit(state, action.windowId);
......
import update from 'lodash/fp/update';
import omit from 'lodash/omit';
import merge from 'lodash/fp/merge';
import ActionTypes from '../actions/action-types';
/**
......@@ -29,7 +28,7 @@ export const windowsReducer = (state = {}, action) => {
};
case ActionTypes.UPDATE_WINDOW:
return update([action.id], orig => merge(orig, action.payload), state);
return update([action.id], orig => ({ ...(orig || {}), ...action.payload }), state);
case ActionTypes.REMOVE_WINDOW:
return omit(state, [action.windowId]);
......@@ -72,7 +71,9 @@ export const windowsReducer = (state = {}, action) => {
case ActionTypes.SET_CANVAS:
if (!state[action.windowId]) return state;
return update([action.windowId], orig => merge(orig, {
return update([action.windowId], orig => (
{
...(orig || {}),
canvasId: action.canvasId,
visibleCanvases: action.visibleCanvases || [],
}), state);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment