File tree Expand file tree Collapse file tree
src/app/item-page/edit-item-page/item-bitstreams Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments