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