From ae8b48bcca40b7f9e057dce7e5332a4a3236d907 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Wed, 19 Oct 2022 08:37:48 -0400 Subject: [PATCH] Fix overcaching annotations. This was caused by #978. --- CHANGELOG.md | 5 +++++ .../web_client/models/AnnotationModel.js | 12 ++++++++++-- .../web_client_specs/annotationSpec.js | 10 ++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a6143a5c..8e5adbfbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 1.17.2 + +### Bug Fixes +- Fixed overcaching annotations ([#983](../../pull/983)) + ## 1.17.1 ### Improvements diff --git a/girder_annotation/girder_large_image_annotation/web_client/models/AnnotationModel.js b/girder_annotation/girder_large_image_annotation/web_client/models/AnnotationModel.js index 2e6c1fe8b..76b84e029 100644 --- a/girder_annotation/girder_large_image_annotation/web_client/models/AnnotationModel.js +++ b/girder_annotation/girder_large_image_annotation/web_client/models/AnnotationModel.js @@ -31,6 +31,9 @@ let AnnotationModel = AccessControlledModel.extend({ }, initialize() { + if (!this.get('updated')) { + this.attributes.updated = '' + Date.now(); // eslint-disable-line backbone/no-model-attributes + } this._region = { maxDetails: this.get('maxDetails'), sort: 'size', @@ -61,7 +64,10 @@ let AnnotationModel = AccessControlledModel.extend({ var url = (this.altUrl || this.resourceName) + '/' + this.get('_id'); var restOpts = { url: url, - data: {sort: 'size', sortdir: -1, centroids: true, limit: this.get('maxCentroids')}, + data: { + sort: 'size', sortdir: -1, centroids: true, limit: this.get('maxCentroids'), + _: (this.get('updated') || this.get('created')) + '_' + this.get('_version') + }, xhrFields: { responseType: 'arraybuffer' }, @@ -180,7 +186,7 @@ let AnnotationModel = AccessControlledModel.extend({ var restOpts = { url: (this.altUrl || this.resourceName) + '/' + this.get('_id'), /* Add our region request into the query */ - data: this._region + data: Object.assign({}, this._region, {_: (this.get('updated') || this.get('created')) + '_' + this.get('_version')}) }; if (opts.extraPath) { restOpts.url += '/' + opts.extraPath; @@ -280,6 +286,7 @@ let AnnotationModel = AccessControlledModel.extend({ } else { url = `annotation/${this.id}`; method = 'PUT'; + this.attributes.updated = '' + Date.now(); // eslint-disable-line backbone/no-model-attributes } if (this._pageElements === false || isNew) { @@ -339,6 +346,7 @@ let AnnotationModel = AccessControlledModel.extend({ this.trigger('g:delete', this, this.collection, options); let xhr = false; if (!this.isNew()) { + this.attributes.updated = '' + Date.now(); // eslint-disable-line backbone/no-model-attributes xhr = restRequest({ url: `annotation/${this.id}`, method: 'DELETE' diff --git a/girder_annotation/test_annotation/web_client_specs/annotationSpec.js b/girder_annotation/test_annotation/web_client_specs/annotationSpec.js index e17d60b9f..5c989646b 100644 --- a/girder_annotation/test_annotation/web_client_specs/annotationSpec.js +++ b/girder_annotation/test_annotation/web_client_specs/annotationSpec.js @@ -451,10 +451,12 @@ describe('Annotations', function () { it('destroy an existing annotation', function () { var done; - annotation.destroy().done(function () { - done = true; - }).fail(function (resp) { - console.error(resp); + runs(function () { + annotation.destroy().done(function () { + done = true; + }).fail(function (resp) { + console.error(resp); + }); }); waitsFor(function () { return done;