1- import { combineLatest as observableCombineLatest } from 'rxjs' ;
1+ import { combineLatest as observableCombineLatest , Observable } from 'rxjs' ;
22import { Component , Inject , PLATFORM_ID } from '@angular/core' ;
33import { ActivatedRoute , Params , Router } from '@angular/router' ;
44import { hasValue } from '../../shared/empty.util' ;
@@ -10,7 +10,7 @@ import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.serv
1010import { BrowseService } from '../../core/browse/browse.service' ;
1111import { SortDirection , SortOptions } from '../../core/cache/models/sort-options.model' ;
1212import { PaginationService } from '../../core/pagination/pagination.service' ;
13- import { map , take } from 'rxjs/operators' ;
13+ import { map , distinctUntilChanged } from 'rxjs/operators' ;
1414import { of as observableOf } from 'rxjs' ;
1515import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model' ;
1616import { AppConfig , APP_CONFIG } from '../../../config/app-config.interface' ;
@@ -48,12 +48,19 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
4848 const sortConfig = new SortOptions ( 'dc.title' , SortDirection . ASC ) ;
4949 this . currentPagination$ = this . paginationService . getCurrentPagination ( this . paginationConfig . id , this . paginationConfig ) ;
5050 this . currentSort$ = this . paginationService . getCurrentSort ( this . paginationConfig . id , sortConfig ) ;
51+ const routeParams$ : Observable < Params > = observableCombineLatest ( [
52+ this . route . params ,
53+ this . route . queryParams ,
54+ ] ) . pipe (
55+ map ( ( [ params , queryParams ] : [ Params , Params ] ) => Object . assign ( { } , params , queryParams ) ) ,
56+ distinctUntilChanged ( ( prev : Params , curr : Params ) => prev . id === curr . id && prev . startsWith === curr . startsWith ) ,
57+ ) ;
5158 this . subs . push (
52- observableCombineLatest ( [ this . route . params . pipe ( take ( 1 ) ) , this . route . queryParams , this . currentPagination$ , this . currentSort$ ] ) . pipe (
53- map ( ( [ routeParams , queryParams , currentPage , currentSort ] ) => {
54- return [ Object . assign ( { } , routeParams , queryParams ) , currentPage , currentSort ] ;
55- } )
56- ) . subscribe ( ( [ params , currentPage , currentSort ] : [ Params , PaginationComponentOptions , SortOptions ] ) => {
59+ observableCombineLatest ( [
60+ routeParams$ ,
61+ this . currentPagination$ ,
62+ this . currentSort$ ,
63+ ] ) . subscribe ( ( [ params , currentPage , currentSort ] : [ Params , PaginationComponentOptions , SortOptions ] ) => {
5764 this . startsWith = + params . startsWith || params . startsWith ;
5865 this . browseId = params . id || this . defaultBrowseId ;
5966 this . updatePageWithItems ( browseParamsToOptions ( params , currentPage , currentSort , this . browseId , this . fetchThumbnails ) , undefined , undefined ) ;
0 commit comments