Select Git revision
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;
}
};