diff --git a/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.ts b/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.ts index ea56a4274a..6fb2ae8c63 100644 --- a/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.ts +++ b/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.ts @@ -244,10 +244,24 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme ), map((bundlePage: PaginatedList) => bundlePage.page), ).subscribe((bundles: Bundle[]) => { - this.bundlesSubject.next([...this.bundlesSubject.getValue(), ...bundles]); + this.updateBundlesSubject(bundles); }); } + updateBundlesSubject(newBundles: Bundle[]) { + const currentBundles = this.bundlesSubject.getValue(); + const bundlesToAdd: Bundle[] = []; + + // Only add bundles to the bundle subject if they are not present yet + newBundles.forEach(newBundle => { + if (!currentBundles.some(currentBundle => currentBundle.id === newBundle.id)) { + bundlesToAdd.push(newBundle); + } + }); + + this.bundlesSubject.next([...currentBundles, ...bundlesToAdd]); + } + /** * Submit the current changes