@@ -16,13 +16,19 @@ import {
1616 RouterOutlet ,
1717} from '@angular/router' ;
1818import { TranslateModule } from '@ngx-translate/core' ;
19- import { Observable } from 'rxjs' ;
2019import {
20+ BehaviorSubject ,
21+ Observable ,
22+ } from 'rxjs' ;
23+ import {
24+ distinctUntilChanged ,
2125 filter ,
2226 map ,
2327 mergeMap ,
28+ switchMap ,
2429 take ,
2530} from 'rxjs/operators' ;
31+ import { CollectionDataService } from 'src/app/core/data/collection-data.service' ;
2632
2733import {
2834 APP_CONFIG ,
@@ -37,7 +43,10 @@ import { RemoteData } from '../core/data/remote-data';
3743import { redirectOn4xx } from '../core/shared/authorized.operators' ;
3844import { Bitstream } from '../core/shared/bitstream.model' ;
3945import { Collection } from '../core/shared/collection.model' ;
40- import { getAllSucceededRemoteDataPayload } from '../core/shared/operators' ;
46+ import {
47+ getAllSucceededRemoteDataPayload ,
48+ getFirstCompletedRemoteData ,
49+ } from '../core/shared/operators' ;
4150import {
4251 fadeIn ,
4352 fadeInOut ,
@@ -48,14 +57,12 @@ import { ThemedComcolPageHandleComponent } from '../shared/comcol/comcol-page-ha
4857import { ComcolPageHeaderComponent } from '../shared/comcol/comcol-page-header/comcol-page-header.component' ;
4958import { ComcolPageLogoComponent } from '../shared/comcol/comcol-page-logo/comcol-page-logo.component' ;
5059import { ContextMenuComponent } from '../shared/context-menu/context-menu.component' ;
51- import { DsoEditMenuComponent } from '../shared/dso-page/dso-edit-menu/dso-edit-menu.component' ;
5260import {
5361 hasValue ,
5462 isNotEmpty ,
5563} from '../shared/empty.util' ;
5664import { ErrorComponent } from '../shared/error/error.component' ;
5765import { ThemedLoadingComponent } from '../shared/loading/themed-loading.component' ;
58- import { ObjectCollectionComponent } from '../shared/object-collection/object-collection.component' ;
5966import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model' ;
6067import { VarDirective } from '../shared/utils/var.directive' ;
6168import { getCollectionPageRoute } from './collection-page-routing-paths' ;
@@ -80,16 +87,14 @@ import { getCollectionPageRoute } from './collection-page-routing-paths';
8087 ComcolPageHeaderComponent ,
8188 ComcolPageLogoComponent ,
8289 ThemedComcolPageHandleComponent ,
83- DsoEditMenuComponent ,
8490 ThemedComcolPageBrowseByComponent ,
85- ObjectCollectionComponent ,
8691 RouterOutlet ,
8792 ContextMenuComponent ,
8893 ] ,
8994 standalone : true ,
9095} )
9196export class CollectionPageComponent implements OnInit {
92- collectionRD$ : Observable < RemoteData < Collection > > ;
97+ collectionRD$ : BehaviorSubject < RemoteData < Collection > > = new BehaviorSubject ( null ) ;
9398 logoRD$ : Observable < RemoteData < Bitstream > > ;
9499 paginationConfig : PaginationComponentOptions ;
95100 sortConfig : SortOptions ;
@@ -111,6 +116,7 @@ export class CollectionPageComponent implements OnInit {
111116 protected router : Router ,
112117 protected authService : AuthService ,
113118 protected authorizationDataService : AuthorizationDataService ,
119+ protected collectionService : CollectionDataService ,
114120 public dsoNameService : DSONameService ,
115121 ) {
116122 }
@@ -120,12 +126,18 @@ export class CollectionPageComponent implements OnInit {
120126 return ;
121127 }
122128
123- this . collectionRD$ = this . route . data . pipe (
124- map ( ( data ) => data . dso as RemoteData < Collection > ) ,
125- redirectOn4xx ( this . router , this . authService ) ,
126- take ( 1 ) ,
127- ) ;
129+ this . route . params . pipe (
130+ map ( params => params . id ) ,
131+ distinctUntilChanged ( ) ,
132+ switchMap ( ( id ) => this . collectionService . findById ( id ) . pipe (
133+ getFirstCompletedRemoteData ( ) ,
134+ redirectOn4xx ( this . router , this . authService ) ,
135+ take ( 1 ) ,
136+ ) ) ,
137+ ) . subscribe ( this . collectionRD$ ) ;
138+
128139 this . logoRD$ = this . collectionRD$ . pipe (
140+ getFirstCompletedRemoteData ( ) ,
129141 map ( ( rd : RemoteData < Collection > ) => rd . payload ) ,
130142 filter ( ( collection : Collection ) => hasValue ( collection ) ) ,
131143 mergeMap ( ( collection : Collection ) => collection . logo ) ,
0 commit comments