You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readarr/frontend/src/Store/Reducers/Creators/createUpdateReducer.js

24 lines
594 B

import _ from 'lodash';
import getSectionState from 'Utilities/State/getSectionState';
import updateSectionState from 'Utilities/State/updateSectionState';
function createUpdateReducer(section) {
return (state, { payload }) => {
if (section === payload.section) {
const newState = getSectionState(state, section);
if (_.isArray(payload.data)) {
newState.items = payload.data;
} else {
newState.item = payload.data;
}
return updateSectionState(state, section, newState);
}
return state;
};
}
export default createUpdateReducer;