diff --git a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.ts b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.ts index 75bbc32700..a47986674f 100644 --- a/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.ts +++ b/src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.ts @@ -20,7 +20,6 @@ import { AlertType } from '../../../shared/alert/aletr-type'; import { Operation } from 'fast-json-patch'; import { METADATA_PATCH_OPERATION_SERVICE_TOKEN } from '../../../core/data/object-updates/patch-operation-service/metadata-patch-operation.service'; import { DSOSuccessResponse } from '../../../core/cache/response.models'; -import { ObjectCacheService } from '../../../core/cache/object-cache.service'; @Component({ selector: 'ds-item-metadata', @@ -57,7 +56,6 @@ export class ItemMetadataComponent extends AbstractItemUpdateComponent { public translateService: TranslateService, public route: ActivatedRoute, public metadataFieldService: RegistryService, - public objectCacheService: ObjectCacheService, ) { super(itemService, objectUpdatesService, router, notificationsService, translateService, route); } @@ -115,9 +113,7 @@ export class ItemMetadataComponent extends AbstractItemUpdateComponent { return this.updateService.patch(this.item, patch).pipe( switchMap((response: DSOSuccessResponse) => { if (isNotEmpty(response.resourceSelfLinks)) { - const selfLink = response.resourceSelfLinks[0]; - this.objectCacheService.addPatch(selfLink, patch, false); - return this.itemService.findByHref(selfLink); + return this.itemService.findByHref(response.resourceSelfLinks[0]); } }), getSucceededRemoteData() diff --git a/src/app/core/cache/object-cache.service.ts b/src/app/core/cache/object-cache.service.ts index 598f168726..745133373d 100644 --- a/src/app/core/cache/object-cache.service.ts +++ b/src/app/core/cache/object-cache.service.ts @@ -270,16 +270,14 @@ export class ObjectCacheService { /** * Add operations to the existing list of operations for an ObjectCacheEntry * Makes sure the ServerSyncBuffer for this ObjectCacheEntry is updated - * @param {string} uuid + * @param selfLink * the uuid of the ObjectCacheEntry * @param {Operation[]} patch * list of operations to perform */ - public addPatch(selfLink: string, patch: Operation[], addToSSD = true) { + public addPatch(selfLink: string, patch: Operation[]) { this.store.dispatch(new AddPatchObjectCacheAction(selfLink, patch)); - if (addToSSD) { - this.store.dispatch(new AddToSSBAction(selfLink, RestRequestMethod.PATCH)); - } + this.store.dispatch(new AddToSSBAction(selfLink, RestRequestMethod.PATCH)); } /** @@ -297,8 +295,8 @@ export class ObjectCacheService { /** * Apply the existing operations on an ObjectCacheEntry in the store * NB: this does not make any server side changes - * @param {string} uuid - * the uuid of the ObjectCacheEntry + * @param selfLink + * the link of the ObjectCacheEntry */ private applyPatchesToCachedObject(selfLink: string) { this.store.dispatch(new ApplyPatchObjectCacheAction(selfLink)); diff --git a/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-add-operation.model.ts b/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-add-operation.model.ts index d9a8ea9d3b..7f9b1d772f 100644 --- a/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-add-operation.model.ts +++ b/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-add-operation.model.ts @@ -22,7 +22,6 @@ export class MetadataPatchAddOperation extends MetadataPatchOperation { * using the information provided. */ toOperation(): Operation { - const path = `/metadata/${this.field}/-`; - return { op: this.op as any, path, value: this.value }; + return { op: this.op as any, path: `/metadata/${this.field}/-`, value: this.value }; } } diff --git a/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-remove-operation.model.ts b/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-remove-operation.model.ts index cd09117c84..61fbae1980 100644 --- a/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-remove-operation.model.ts +++ b/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-remove-operation.model.ts @@ -1,6 +1,5 @@ import { MetadataPatchOperation } from './metadata-patch-operation.model'; import { Operation } from 'fast-json-patch'; -import { hasValue } from '../../../../../../shared/empty.util'; /** * Wrapper object for a metadata patch remove Operation @@ -23,10 +22,6 @@ export class MetadataPatchRemoveOperation extends MetadataPatchOperation { * using the information provided. */ toOperation(): Operation { - let path = `/metadata/${this.field}`; - if (hasValue(this.place)) { - path += `/${this.place}`; - } - return { op: this.op as any, path }; + return { op: this.op as any, path: `/metadata/${this.field}/${this.place}` }; } } diff --git a/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-replace-operation.model.ts b/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-replace-operation.model.ts index 29859e0a8f..e889bede0b 100644 --- a/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-replace-operation.model.ts +++ b/src/app/core/data/object-updates/patch-operation-service/operations/metadata/metadata-patch-replace-operation.model.ts @@ -1,6 +1,5 @@ import { MetadataPatchOperation } from './metadata-patch-operation.model'; import { Operation } from 'fast-json-patch'; -import { hasValue } from '../../../../../../shared/empty.util'; /** * Wrapper object for a metadata patch replace Operation @@ -29,10 +28,6 @@ export class MetadataPatchReplaceOperation extends MetadataPatchOperation { * using the information provided. */ toOperation(): Operation { - let path = `/metadata/${this.field}`; - if (hasValue(this.place)) { - path += `/${this.place}`; - } - return { op: this.op as any, path, value: this.value }; + return { op: this.op as any, path: `/metadata/${this.field}/${this.place}`, value: this.value }; } }