From 02be3e0ad5fcbad266113e5fb7852daa27314e00 Mon Sep 17 00:00:00 2001 From: Andreas Awouters Date: Wed, 30 Apr 2025 13:42:51 +0200 Subject: [PATCH] 130484: Only add bundles when they are missing from the subject --- .../item-bitstreams/item-bitstreams.component.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 581b8b4bcb..4bbbea0741 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 @@ -192,10 +192,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