mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
130484: Only add bundles when they are missing from the subject
This commit is contained in:
@@ -192,10 +192,24 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme
|
||||
),
|
||||
map((bundlePage: PaginatedList<Bundle>) => 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
|
||||
|
Reference in New Issue
Block a user