130484: Filter new bundles

This commit is contained in:
Andreas Awouters
2025-04-30 15:49:59 +02:00
parent 50f7ebf1b9
commit 2b2aebffd9

View File

@@ -253,14 +253,10 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme
*/
updateBundles(newBundlesPL: PaginatedList<Bundle>) {
const currentBundles = this.bundlesSubject.getValue();
const bundlesToAdd: Bundle[] = [];
// Only add bundles to the bundle subject if they are not present yet
newBundlesPL.page.forEach(newBundle => {
if (!currentBundles.some(currentBundle => currentBundle.id === newBundle.id)) {
bundlesToAdd.push(newBundle);
}
});
const bundlesToAdd = newBundlesPL.page
.filter(bundleToAdd => !currentBundles.some(currentBundle => currentBundle.id === bundleToAdd.id));
const updatedBundles = [...currentBundles, ...bundlesToAdd];