receptor/src/reducers/selection.js

15 lines
408 B
JavaScript
Raw Normal View History

import { UNION, SUBTRACT, EXCLUSIVE, NONE } from '../actions/selection';
export default function selection(state = [], action) {
2017-08-26 01:59:53 +02:00
const { ids } = action;
switch (action.type) {
case UNION:
2017-08-26 01:59:53 +02:00
return [...ids, ...state.filter(id => ids.indexOf(id) === -1)];
case SUBTRACT:
2017-08-26 01:59:53 +02:00
return state.filter(id => ids.indexOf(id) === -1);
case EXCLUSIVE:
2017-08-26 01:59:53 +02:00
return [...ids];
}
return state;
}