Files
ohif-viewer/platform/viewer/src/components/StudyLoadingMonitor.js
T

42 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-08-13 15:36:46 -04:00
import { Component } from "react";
import PropTypes from "prop-types";
import OHIF from "@ohif/core";
2019-01-10 13:30:39 +01:00
class StudyLoadingMonitor extends Component {
2019-05-29 08:39:54 -04:00
static propTypes = {
studies: PropTypes.array.isRequired,
setStudyLoadingProgress: PropTypes.func.isRequired,
2019-08-13 15:36:46 -04:00
clearStudyLoadingProgress: PropTypes.func.isRequired
2019-05-29 08:39:54 -04:00
};
2019-01-10 13:30:39 +01:00
2019-05-29 08:39:54 -04:00
componentDidMount() {
// TODO: This is pretty ugly. The thing is that the StudyLoadingListener
// needs to update the Redux store, but shouldn't know that it exists.
// I am therefore passing in some functions to update the store instead,
// but this should definitely be cleaned up somehow.
const options = {
_setProgressData: (progressId, progressData) => {
this.props.setStudyLoadingProgress(progressId, progressData);
},
_clearProgressById: progressId => {
this.props.clearStudyLoadingProgress(progressId);
2019-08-13 15:36:46 -04:00
}
2019-05-29 08:39:54 -04:00
};
2019-01-10 13:30:39 +01:00
2019-05-29 08:39:54 -04:00
const { StudyLoadingListener } = OHIF.classes;
this.studyLoadingListener = StudyLoadingListener.getInstance(options);
this.studyLoadingListener.clear();
this.studyLoadingListener.addStudies(this.props.studies);
}
2019-01-10 13:30:39 +01:00
2019-05-29 08:39:54 -04:00
render() {
return null;
}
2019-01-10 13:30:39 +01:00
2019-05-29 08:39:54 -04:00
componentWillUnmount() {
// Destroy stack loading listeners when we close the viewer
this.studyLoadingListener.clear();
}
2019-01-10 13:30:39 +01:00
}
export default StudyLoadingMonitor;