Skip to content
Snippets Groups Projects
Select Git revision
  • 2b769cee7124757b1d1ee57e105c55d853d2d85f
  • master default protected
  • dev
3 results

page.php

Blame
  • viewers.js 898 B
    import { setIn } from 'immutable';
    import ActionTypes from '../actions/action-types';
    
    /**
     * viewersReducer
     */
    export const viewersReducer = (state = {}, action) => {
      switch (action.type) {
        case ActionTypes.UPDATE_VIEWPORT:
          return {
            ...state,
            [action.windowId]: {
              ...action.payload,
            },
          };
        case ActionTypes.REMOVE_WINDOW:
          return Object.keys(state).reduce((object, key) => {
            if (key !== action.windowId) {
              object[key] = state[key]; // eslint-disable-line no-param-reassign
            }
            return object;
          }, {});
        case ActionTypes.SET_WINDOW_VIEW_TYPE:
          return setIn(state, [action.windowId], null);
        case ActionTypes.SET_CANVAS:
          return setIn(state, [action.windowId], null);
        case ActionTypes.IMPORT_MIRADOR_STATE:
          return action.state.viewers;
        default:
          return state;
      }
    };