Skip to content

Commit

Permalink
Merge pull request #317 from DigitalSlideArchive/better-annotation-up…
Browse files Browse the repository at this point in the history
…date

Better update annotations when they change from external causes
  • Loading branch information
manthey authored Jun 30, 2023
2 parents 2f09259 + 96c0b81 commit bb7c47c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions histomicsui/web_client/panels/AnnotationSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ var AnnotationSelector = Panel.extend({
this.listenTo(this.collection, 'change:highlight', this._changeAnnotationHighlight);
this.listenTo(eventStream, 'g:event.job_status', _.debounce(this._onJobUpdate, 500));
this.listenTo(eventStream, 'g:eventStream.start', this._refreshAnnotations);
this.listenTo(eventStream, 'g:event.large_image_annotation.create', this._refreshAnnotations);
this.listenTo(eventStream, 'g:event.large_image_annotation.remove', this._refreshAnnotations);
this.listenTo(this.collection, 'change:annotation change:groups', this._saveAnnotation);
this.listenTo(girderEvents, 'g:login', () => {
this.collection.reset();
Expand Down Expand Up @@ -240,6 +242,10 @@ var AnnotationSelector = Panel.extend({
},

_refreshAnnotations() {
if (this._norefresh) {
delete this._norefresh;
return;
}
if (!this.parentItem || !this.parentItem.id || !this.viewer) {
return;
}
Expand Down Expand Up @@ -290,6 +296,9 @@ var AnnotationSelector = Panel.extend({
this._deselectAnnotationElements(models[id]);
this.viewer.removeAnnotation(models[id]);
}
if (activeId === id) {
this.trigger('h:deleteAnnotation', models[id]);
}
});
return null;
});
Expand Down Expand Up @@ -389,6 +398,7 @@ var AnnotationSelector = Panel.extend({
showSaveAnnotationDialog(model, {title: 'Create annotation'}),
'g:submit',
() => {
this._norefresh = true;
model.save().done(() => {
model.set('displayed', true);
this.collection.add(model);
Expand Down

0 comments on commit bb7c47c

Please sign in to comment.