Skip to content
Snippets Groups Projects
Commit 592e8b1e authored by Chris Beer's avatar Chris Beer
Browse files

Move the redux store into the viewer instance

parent 6b13ab2f
Branches
Tags
No related merge requests found
...@@ -8,7 +8,6 @@ import createStore from '../state/createStore'; ...@@ -8,7 +8,6 @@ import createStore from '../state/createStore';
import * as actions from '../state/actions'; import * as actions from '../state/actions';
import settings from '../config/settings'; import settings from '../config/settings';
const store = createStore();
/** /**
* Default Mirador instantiation * Default Mirador instantiation
*/ */
...@@ -16,16 +15,17 @@ class MiradorViewer { ...@@ -16,16 +15,17 @@ class MiradorViewer {
/** /**
*/ */
constructor(config) { constructor(config) {
this.store = createStore();
this.config = config; this.config = config;
this.processPlugins(); this.processPlugins();
this.processConfig(); this.processConfig();
const viewer = { const viewer = {
actions, actions,
store, store: this.store,
}; };
ReactDOM.render( ReactDOM.render(
<Provider store={store}> <Provider store={this.store}>
<App config={config} /> <App config={config} />
</Provider>, </Provider>,
document.getElementById(config.id), document.getElementById(config.id),
...@@ -40,7 +40,7 @@ class MiradorViewer { ...@@ -40,7 +40,7 @@ class MiradorViewer {
processConfig() { processConfig() {
const mergedConfig = deepmerge(settings, this.config); const mergedConfig = deepmerge(settings, this.config);
const action = actions.setConfig(mergedConfig); const action = actions.setConfig(mergedConfig);
store.dispatch(action); this.store.dispatch(action);
mergedConfig.windows.forEach((miradorWindow) => { mergedConfig.windows.forEach((miradorWindow) => {
let thumbnailNavigationPosition; let thumbnailNavigationPosition;
...@@ -49,8 +49,8 @@ class MiradorViewer { ...@@ -49,8 +49,8 @@ class MiradorViewer {
} else { } else {
thumbnailNavigationPosition = mergedConfig.thumbnailNavigation.defaultPosition; thumbnailNavigationPosition = mergedConfig.thumbnailNavigation.defaultPosition;
} }
store.dispatch(actions.fetchManifest(miradorWindow.loadedManifest)); this.store.dispatch(actions.fetchManifest(miradorWindow.loadedManifest));
store.dispatch(actions.addWindow({ this.store.dispatch(actions.addWindow({
canvasIndex: (miradorWindow.canvasIndex || 0), canvasIndex: (miradorWindow.canvasIndex || 0),
manifestId: miradorWindow.loadedManifest, manifestId: miradorWindow.loadedManifest,
thumbnailNavigationPosition, thumbnailNavigationPosition,
...@@ -88,8 +88,8 @@ class MiradorViewer { ...@@ -88,8 +88,8 @@ class MiradorViewer {
}); });
actionCreators.forEach((action) => { actions[action.name] = action.action; }); actionCreators.forEach((action) => { actions[action.name] = action.action; });
reducers.forEach((reducer) => { store.pluginReducers[reducer.name] = reducer.reducer; }); reducers.forEach((reducer) => { this.store.pluginReducers[reducer.name] = reducer.reducer; });
store.replaceReducer(createRootReducer(store.pluginReducers)); this.store.replaceReducer(createRootReducer(this.store.pluginReducers));
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment