about summary refs log tree commit diff
path: root/app/assets/javascripts/components/reducers/modal.jsx
blob: b529b6aa8f1c6c4b97c208c64f582d936adf1d98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { MEDIA_OPEN, MODAL_CLOSE } from '../actions/modal';
import Immutable                   from 'immutable';

const initialState = Immutable.Map({
  url: '',
  open: false
});

export default function modal(state = initialState, action) {
  switch(action.type) {
    case MEDIA_OPEN:
      return state.withMutations(map => {
        map.set('url', action.url);
        map.set('open', true);
      });
    case MODAL_CLOSE:
      return state.set('open', false);
    default:
      return state;
  }
};