Skip to content
Snippets Groups Projects
Commit 99779b08 authored by Jack Reed's avatar Jack Reed Committed by Chris Beer
Browse files

Reset the viewer state for a window when a canvas or viewertype changes

parent f87bfa38
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,42 @@ describe('viewers reducer', () => {
},
});
});
it('should handle SET_WINDOW_VIEW_TYPE', () => {
expect(viewersReducer({
abc123: {
foo: 'bar',
},
def456: {
foo: 'bar',
},
}, {
type: ActionTypes.SET_WINDOW_VIEW_TYPE,
windowId: 'abc123',
})).toEqual({
abc123: null,
def456: {
foo: 'bar',
},
});
});
it('should handle SET_CANVAS', () => {
expect(viewersReducer({
abc123: {
foo: 'bar',
},
def456: {
foo: 'bar',
},
}, {
type: ActionTypes.SET_CANVAS,
windowId: 'abc123',
})).toEqual({
abc123: null,
def456: {
foo: 'bar',
},
});
});
it('should handle IMPORT_MIRADOR_STATE', () => {
expect(viewersReducer({}, {
state: { viewers: { new: 'stuff' } },
......
import { setIn } from 'immutable';
import ActionTypes from '../actions/action-types';
/**
......@@ -19,6 +20,10 @@ export const viewersReducer = (state = {}, action) => {
}
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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment