about summary refs log tree commit diff
path: root/app/assets/javascripts/components/reducers/modal.jsx
blob: ac53ea21028511bd29923e5612ba116a7ce36981 (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;
  }
};