diff --git a/extensions/ohif-cornerstone-extension/src/ConnectedCornerstoneViewport.js b/extensions/ohif-cornerstone-extension/src/ConnectedCornerstoneViewport.js index 7f1979998..f0d775047 100644 --- a/extensions/ohif-cornerstone-extension/src/ConnectedCornerstoneViewport.js +++ b/extensions/ohif-cornerstone-extension/src/ConnectedCornerstoneViewport.js @@ -4,6 +4,21 @@ import { connect } from 'react-redux'; import throttle from 'lodash.throttle'; const { setViewportActive, setViewportSpecificData } = OHIF.redux.actions; +const { + onAdded, + onRemoved, + onModified, +} = OHIF.measurements.MeasurementHandlers; + +// TODO: Transition to enums for the action names so that we can ensure they stay up to date +// everywhere they're used. +const MEASUREMENT_ACTION_MAP = { + 'added': onAdded, + 'removed': onRemoved, + 'modified': throttle(event => { + return onModified(event); + }, 300), +} const mapStateToProps = (state, ownProps) => { let dataFromStore; @@ -71,20 +86,7 @@ const mapDispatchToProps = (dispatch, ownProps) => { }, onMeasurementsChanged: (event, action) => { - const { - onAdded, - onRemoved, - onModified, - } = OHIF.measurements.MeasurementHandlers; - const actions = { - added: onAdded, - removed: onRemoved, - modified: throttle(event => { - return onModified(event); - }, 300), - }; - - return actions[action](event); + return MEASUREMENT_ACTION_MAP[action](event); }, }; };