Lidarr/frontend/src/Store/Reducers/Creators/createSetReducer.js

24 lines
569 B
JavaScript
Raw Normal View History

2017-09-04 02:20:56 +00:00
import _ from 'lodash';
import getSectionState from 'Utilities/State/getSectionState';
import updateSectionState from 'Utilities/State/updateSectionState';
const blacklistedProperties = [
'section',
'id'
];
function createSetReducer(section) {
return (state, { payload }) => {
if (section === payload.section) {
const newState = Object.assign(getSectionState(state, section),
2017-10-07 06:21:06 +00:00
_.omit(payload, blacklistedProperties));
2017-09-04 02:20:56 +00:00
return updateSectionState(state, section, newState);
}
return state;
};
}
export default createSetReducer;