empty viewport, prevent duplicate series meta from add, protect broadcast events when no data has changed
This commit is contained in:
1 parent
692f4c1ca5
commit
c9a4ab13ef
13 files changed
+198
-146
No files matched your search
@@ -72,11 +72,16 @@ const BaseImplementation = {
|
||||
study = _model.studies[_model.studies.length - 1];
|
||||
}
|
||||
|
||||
study.addSeries(instances);
|
||||
this._broadcastEvent(EVENTS.INSTANCES_ADDED, {
|
||||
StudyInstanceUID,
|
||||
SeriesInstanceUID,
|
||||
});
|
||||
// TODO: Worth identifying why this is being called many times with series
|
||||
// that are already "added"?
|
||||
const didAddSeries = study.addSeries(instances);
|
||||
|
||||
if (didAddSeries) {
|
||||
this._broadcastEvent(EVENTS.INSTANCES_ADDED, {
|
||||
StudyInstanceUID,
|
||||
SeriesInstanceUID,
|
||||
});
|
||||
}
|
||||
},
|
||||
addStudy(study) {
|
||||
const { StudyInstanceUID } = study;
|
||||
|
||||
@@ -4,9 +4,24 @@ function createStudyMetadata(StudyInstanceUID) {
|
||||
return {
|
||||
StudyInstanceUID,
|
||||
series: [],
|
||||
/**
|
||||
*
|
||||
* @param {object[]} instances
|
||||
* @param {string} instances[].SeriesInstanceUID
|
||||
* @returns {bool} true if series were added; false if series already exist
|
||||
*/
|
||||
addSeries: function(instances) {
|
||||
const series = createSeriesMetadata(instances);
|
||||
this.series.push(series);
|
||||
const { SeriesInstanceUID } = instances[0];
|
||||
const seriesExists = this.series.some(
|
||||
s => s.SeriesInstanceUID === SeriesInstanceUID
|
||||
);
|
||||
|
||||
if (!seriesExists) {
|
||||
const series = createSeriesMetadata(instances);
|
||||
this.series.push(series);
|
||||
}
|
||||
|
||||
return !seriesExists;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ const displaySetCache = [];
|
||||
export default class DisplaySetService {
|
||||
constructor() {
|
||||
this.displaySets = {};
|
||||
this.activeDisplaySets = [];
|
||||
this.listeners = {};
|
||||
this.EVENTS = EVENTS;
|
||||
|
||||
@@ -77,9 +78,10 @@ export default class DisplaySetService {
|
||||
displaySetsAdded = displaySets;
|
||||
}
|
||||
|
||||
// TODO: This is tricky. How do we know we're not resetting to the same/existing DSs?
|
||||
// TODO: This is likely run anytime we touch DicomMetadataStore. How do we prevent uneccessary broadcasts?
|
||||
if (displaySetsAdded && displaySetsAdded.length) {
|
||||
this._broadcastEvent(EVENTS.DISPLAY_SETS_ADDED, displaySetsAdded);
|
||||
|
||||
this._broadcastEvent(EVENTS.DISPLAY_SETS_CHANGED, this.activeDisplaySets);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ export default {
|
||||
};
|
||||
|
||||
/**
|
||||
* Subscribe to measurement updates.
|
||||
* Subscribe to updates.
|
||||
*
|
||||
* @param {string} eventName The name of the event
|
||||
* @param {Function} callback Events callback
|
||||
@@ -24,7 +24,7 @@ function subscribe(eventName, callback) {
|
||||
const listenerId = guid();
|
||||
const subscription = { id: listenerId, callback };
|
||||
|
||||
console.info(`displaySetService: Subscribing to '${eventName}'.`);
|
||||
console.info(`Subscribing to '${eventName}'.`);
|
||||
if (Array.isArray(this.listeners[eventName])) {
|
||||
this.listeners[eventName].push(subscription);
|
||||
} else {
|
||||
@@ -60,7 +60,7 @@ function _unsubscribe(eventName, listenerId) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given displaySetService event is valid.
|
||||
* Check if a given event is valid.
|
||||
*
|
||||
* @param {string} eventName The name of the event
|
||||
* @return {boolean} Event name validation
|
||||
@@ -70,7 +70,7 @@ function _isValidEvent(eventName) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts displaySetService changes.
|
||||
* Broadcasts changes.
|
||||
*
|
||||
* @param {string} eventName - The event name
|
||||
* @param {func} callbackProps - Properties to pass callback
|
||||
|
||||
Reference in new issue
Block a user