fix(viewport): Fix active viewport by connecting to redux
This commit is contained in:
1 parent
943efb44e5
commit
83a7271cd1
8 files changed
+78
-35
No files matched your search
@@ -12,6 +12,7 @@ import './ViewerMain.styl';
|
||||
import { Component } from 'react';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Provider } from 'react-redux';
|
||||
|
||||
Meteor.startup(() => {
|
||||
window.ResizeViewportManager = window.ResizeViewportManager || new ResizeViewportManager();
|
||||
@@ -21,6 +22,8 @@ Meteor.startup(() => {
|
||||
Session.set('OHIFViewerMainRendered', false);
|
||||
});
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
class ViewerMain extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -60,7 +63,19 @@ class ViewerMain extends Component {
|
||||
}
|
||||
|
||||
setContents(Component, props) {
|
||||
const contents = (<Component {...props}/>);
|
||||
// TODO[react] Not sure I like this piece much
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
activeViewportIndex: state.viewports.activeViewportIndex,
|
||||
};
|
||||
};
|
||||
|
||||
const ConnectedComponent = connect(
|
||||
mapStateToProps,
|
||||
null
|
||||
)(Component);
|
||||
|
||||
const contents = (<ConnectedComponent {...props}/>);
|
||||
|
||||
this.setState({
|
||||
contents
|
||||
@@ -69,9 +84,11 @@ class ViewerMain extends Component {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="viewerMain">
|
||||
{this.state.contents}
|
||||
</div>
|
||||
<Provider store={window.store}>
|
||||
<div className="viewerMain">
|
||||
{this.state.contents}
|
||||
</div>
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user