Skip to content

Commit

Permalink
Fix overcaching annotations.
Browse files Browse the repository at this point in the history
This was caused by #978.
  • Loading branch information
manthey committed Oct 19, 2022
1 parent 1a7ba44 commit ae8b48b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 1.17.2

### Bug Fixes
- Fixed overcaching annotations ([#983](../../pull/983))

## 1.17.1

### Improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'
},
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ae8b48b

Please sign in to comment.