Skip to content

Commit

Permalink
fix(properties): resolve 409 conflict (#822)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelez committed Sep 14, 2022
1 parent 88a2cbd commit bf0ed83
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/app/workspace/resource/properties/properties.component.ts
Expand Up @@ -343,22 +343,28 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy {

// update resource's label if it has changed
if (this.resource.res.label !== answer.comment) {
const payload = new UpdateResourceMetadata();
payload.id = this.resource.res.id;
payload.type = this.resource.res.type;
payload.lastModificationDate = this.lastModificationDate;
payload.label = answer.comment;
this._dspApiConnection.v2.res.updateResourceMetadata(payload).subscribe(
(response: UpdateResourceMetadataResponse) => {
this.resource.res.label = payload.label;
this.lastModificationDate = response.lastModificationDate;
// if annotations tab is active; a label of a region has been changed --> update regions
if (this.isAnnotation) {
this.regionChanged.emit();
}
},
(error: ApiResponseError) => {
this._errorHandler.showMessage(error);
// get the correct lastModificationDate from the resource
this._dspApiConnection.v2.res.getResource(this.resource.res.id).subscribe(
(res: ReadResource) => {
const payload = new UpdateResourceMetadata();
payload.id = this.resource.res.id;
payload.type = this.resource.res.type;
payload.lastModificationDate = res.lastModificationDate;
payload.label = answer.comment;

this._dspApiConnection.v2.res.updateResourceMetadata(payload).subscribe(
(response: UpdateResourceMetadataResponse) => {
this.resource.res.label = payload.label;
this.lastModificationDate = response.lastModificationDate;
// if annotations tab is active; a label of a region has been changed --> update regions
if (this.isAnnotation) {
this.regionChanged.emit();
}
},
(error: ApiResponseError) => {
this._errorHandler.showMessage(error);
}
);
}
);
}
Expand Down

0 comments on commit bf0ed83

Please sign in to comment.