Skip to content

Commit d3b48f4

Browse files
committed
130484: Only add bundles when they are missing from the subject
1 parent 5719f06 commit d3b48f4

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,24 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme
244244
),
245245
map((bundlePage: PaginatedList<Bundle>) => bundlePage.page),
246246
).subscribe((bundles: Bundle[]) => {
247-
this.bundlesSubject.next([...this.bundlesSubject.getValue(), ...bundles]);
247+
this.updateBundlesSubject(bundles);
248248
});
249249
}
250250

251+
updateBundlesSubject(newBundles: Bundle[]) {
252+
const currentBundles = this.bundlesSubject.getValue();
253+
const bundlesToAdd: Bundle[] = [];
254+
255+
// Only add bundles to the bundle subject if they are not present yet
256+
newBundles.forEach(newBundle => {
257+
if (!currentBundles.some(currentBundle => currentBundle.id === newBundle.id)) {
258+
bundlesToAdd.push(newBundle);
259+
}
260+
});
261+
262+
this.bundlesSubject.next([...currentBundles, ...bundlesToAdd]);
263+
}
264+
251265

252266
/**
253267
* Submit the current changes

0 commit comments

Comments
 (0)