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.

16 lines
702 B

  1. import { MODAL_OPEN, MODAL_CLOSE } from '../actions/modal';
  2. import { TIMELINE_DELETE } from '../actions/timelines';
  3. import { Stack as ImmutableStack, Map as ImmutableMap } from 'immutable';
  4. export default function modal(state = ImmutableStack(), action) {
  5. switch(action.type) {
  6. case MODAL_OPEN:
  7. return state.unshift(ImmutableMap({ modalType: action.modalType, modalProps: action.modalProps }));
  8. case MODAL_CLOSE:
  9. return (action.modalType === undefined || action.modalType === state.getIn([0, 'modalType'])) ? state.shift() : state;
  10. case TIMELINE_DELETE:
  11. return state.filterNot((modal) => modal.get('modalProps').statusId === action.id);
  12. default:
  13. return state;
  14. }
  15. };