diff --git a/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts b/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts index e0738d39b4..acd13137e5 100644 --- a/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts +++ b/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts @@ -4,7 +4,7 @@ import { ObjectUpdatesService } from '../../../../core/data/object-updates/objec import { Observable } from 'rxjs/internal/Observable'; import { FieldUpdates } from '../../../../core/data/object-updates/object-updates.reducer'; import { toBitstreamsArray } from '../../../../core/shared/item-bitstreams-utils'; -import { map, switchMap, tap } from 'rxjs/operators'; +import { map, switchMap, take, tap } from 'rxjs/operators'; import { Bitstream } from '../../../../core/shared/bitstream.model'; import { Item } from '../../../../core/shared/item.model'; import { CdkDragDrop } from '@angular/cdk/drag-drop'; @@ -89,6 +89,7 @@ export class ItemEditBitstreamBundleComponent implements OnInit { this.updates$ = this.bitstreamsRD$.pipe( toBitstreamsArray(), tap((bitstreams: Bitstream[]) => this.objectUpdatesService.initialize(this.bundle.self, bitstreams, new Date(), true)), + take(1), switchMap((bitstreams: Bitstream[]) => this.objectUpdatesService.getFieldUpdatesByCustomOrder(this.bundle.self, bitstreams)) ); this.isLoadingMore$ = observableCombineLatest(this.currentSize$, this.bitstreamsRD$).pipe( diff --git a/src/app/core/data/bitstream-data.service.spec.ts b/src/app/core/data/bitstream-data.service.spec.ts index b6d6a00f84..6dd523d5b6 100644 --- a/src/app/core/data/bitstream-data.service.spec.ts +++ b/src/app/core/data/bitstream-data.service.spec.ts @@ -46,22 +46,6 @@ describe('BitstreamDataService', () => { service = new BitstreamDataService(requestService, null, null, null, null, objectCache, halService, null, null, null, bitstreamFormatService); }); - describe('when deleting a bitstream', () => { - let response$: Observable; - - beforeEach(() => { - response$ = service.deleteAndReturnResponse(bitstream); - }); - - it('should de-cache the bitstream\'s object cache', () => { - expect(objectCache.remove).toHaveBeenCalledWith(bitstream.self); - }); - - it('should de-cache the bitstream\'s request cache', () => { - expect(requestService.removeByHrefSubstring).toHaveBeenCalledWith(bitstream.self); - }); - }); - describe('when updating the bitstream\'s format', () => { beforeEach(() => { service.updateFormat(bitstream, format); diff --git a/src/app/core/data/bitstream-data.service.ts b/src/app/core/data/bitstream-data.service.ts index 8c06b126bf..9cb4f8ad00 100644 --- a/src/app/core/data/bitstream-data.service.ts +++ b/src/app/core/data/bitstream-data.service.ts @@ -61,19 +61,6 @@ export class BitstreamDataService extends DataService { return this.halService.getEndpoint(linkPath); } - /** - * Delete an existing DSpace Object on the server - * @param bitstream The Bitstream to be removed - * De-cache the removed bitstream from Object and Request cache - * Return an observable of the completed response - */ - deleteAndReturnResponse(bitstream: Bitstream): Observable { - const response$ = super.deleteAndReturnResponse(bitstream); - this.objectCache.remove(bitstream.self); - this.requestService.removeByHrefSubstring(bitstream.self); - return response$; - } - /** * Set the format of a bitstream * @param bitstream diff --git a/src/app/core/data/data.service.ts b/src/app/core/data/data.service.ts index e5e9c472f7..318bccead7 100644 --- a/src/app/core/data/data.service.ts +++ b/src/app/core/data/data.service.ts @@ -4,7 +4,7 @@ import { Observable } from 'rxjs'; import { distinctUntilChanged, filter, find, first, map, mergeMap, switchMap, take } from 'rxjs/operators'; import { Store } from '@ngrx/store'; -import { hasValue, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util'; +import { hasValue, hasValueOperator, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { CoreState } from '../core.reducers'; import { HALEndpointService } from '../shared/hal-endpoint.service'; @@ -327,6 +327,7 @@ export abstract class DataService { const requestId = this.deleteAndReturnRequestId(dso); return this.requestService.getByUUID(requestId).pipe( + hasValueOperator(), find((request: RequestEntry) => request.completed), map((request: RequestEntry) => request.response) );