99 OnChanges ,
1010 OnDestroy ,
1111 OnInit ,
12+ SimpleChanges ,
1213} from '@angular/core' ;
1314import {
1415 ActivatedRoute ,
@@ -24,8 +25,8 @@ import {
2425 Subscription ,
2526} from 'rxjs' ;
2627import {
28+ distinctUntilChanged ,
2729 map ,
28- take ,
2930} from 'rxjs/operators' ;
3031import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component' ;
3132
@@ -48,20 +49,13 @@ import { BrowseEntry } from '../../core/shared/browse-entry.model';
4849import { Context } from '../../core/shared/context.model' ;
4950import { Item } from '../../core/shared/item.model' ;
5051import { getFirstSucceededRemoteData } from '../../core/shared/operators' ;
51- import { ThemedComcolPageBrowseByComponent } from '../../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component' ;
52- import { ThemedComcolPageContentComponent } from '../../shared/comcol/comcol-page-content/themed-comcol-page-content.component' ;
53- import { ThemedComcolPageHandleComponent } from '../../shared/comcol/comcol-page-handle/themed-comcol-page-handle.component' ;
54- import { ComcolPageHeaderComponent } from '../../shared/comcol/comcol-page-header/comcol-page-header.component' ;
55- import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component' ;
56- import { DsoEditMenuComponent } from '../../shared/dso-page/dso-edit-menu/dso-edit-menu.component' ;
5752import {
5853 hasValue ,
5954 isNotEmpty ,
6055} from '../../shared/empty.util' ;
6156import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component' ;
6257import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model' ;
6358import { StartsWithType } from '../../shared/starts-with/starts-with-type' ;
64- import { VarDirective } from '../../shared/utils/var.directive' ;
6559import { BrowseByDataType } from '../browse-by-switcher/browse-by-data-type' ;
6660
6761export const BBM_PAGINATION_ID = 'bbm' ;
@@ -71,15 +65,8 @@ export const BBM_PAGINATION_ID = 'bbm';
7165 styleUrls : [ './browse-by-metadata.component.scss' ] ,
7266 templateUrl : './browse-by-metadata.component.html' ,
7367 imports : [
74- VarDirective ,
7568 AsyncPipe ,
76- ComcolPageHeaderComponent ,
77- ComcolPageLogoComponent ,
7869 NgIf ,
79- ThemedComcolPageHandleComponent ,
80- ThemedComcolPageContentComponent ,
81- DsoEditMenuComponent ,
82- ThemedComcolPageBrowseByComponent ,
8370 TranslateModule ,
8471 ThemedLoadingComponent ,
8572 ThemedBrowseByComponent ,
@@ -215,21 +202,22 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
215202 ngOnInit ( ) : void {
216203
217204 const sortConfig = new SortOptions ( 'default' , SortDirection . ASC ) ;
218- this . updatePage ( getBrowseSearchOptions ( this . defaultBrowseId , this . paginationConfig , sortConfig ) ) ;
219205 this . currentPagination$ = this . paginationService . getCurrentPagination ( this . paginationConfig . id , this . paginationConfig ) ;
220206 this . currentSort$ = this . paginationService . getCurrentSort ( this . paginationConfig . id , sortConfig ) ;
207+ const routeParams$ : Observable < Params > = observableCombineLatest ( [
208+ this . route . params ,
209+ this . route . queryParams ,
210+ ] ) . pipe (
211+ map ( ( [ params , queryParams ] : [ Params , Params ] ) => Object . assign ( { } , params , queryParams ) ) ,
212+ distinctUntilChanged ( ( prev : Params , curr : Params ) => prev . id === curr . id && prev . authority === curr . authority && prev . value === curr . value && prev . startsWith === curr . startsWith ) ,
213+ ) ;
221214 this . subs . push (
222- observableCombineLatest (
223- [ this . route . params . pipe ( take ( 1 ) ) ,
224- this . route . queryParams ,
225- this . scope$ ,
226- this . currentPagination$ ,
227- this . currentSort$ ,
228- ] ) . pipe (
229- map ( ( [ routeParams , queryParams , scope , currentPage , currentSort ] ) => {
230- return [ Object . assign ( { } , routeParams , queryParams ) , scope , currentPage , currentSort ] ;
231- } ) ,
232- ) . subscribe ( ( [ params , scope , currentPage , currentSort ] : [ Params , string , PaginationComponentOptions , SortOptions ] ) => {
215+ observableCombineLatest ( [
216+ routeParams$ ,
217+ this . scope$ ,
218+ this . currentPagination$ ,
219+ this . currentSort$ ,
220+ ] ) . subscribe ( ( [ params , scope , currentPage , currentSort ] : [ Params , string , PaginationComponentOptions , SortOptions ] ) => {
233221 this . browseId = params . id || this . defaultBrowseId ;
234222 this . authority = params . authority ;
235223
@@ -257,8 +245,10 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
257245
258246 }
259247
260- ngOnChanges ( ) : void {
261- this . scope$ . next ( this . scope ) ;
248+ ngOnChanges ( changes : SimpleChanges ) : void {
249+ if ( hasValue ( changes . scope ) ) {
250+ this . scope$ . next ( this . scope ) ;
251+ }
262252 }
263253
264254 /**
0 commit comments