@@ -11,7 +11,6 @@ import {
1111} from '@angular/core' ;
1212import {
1313 ActivatedRoute ,
14- Params ,
1514 Router ,
1615} from '@angular/router' ;
1716import { TranslateModule } from '@ngx-translate/core' ;
@@ -21,8 +20,8 @@ import {
2120 of ,
2221} from 'rxjs' ;
2322import {
24- distinctUntilChanged ,
2523 map ,
24+ switchMap ,
2625} from 'rxjs/operators' ;
2726import { ThemedBrowseByComponent } from 'src/app/shared/browse-by/themed-browse-by.component' ;
2827
@@ -47,7 +46,6 @@ import {
4746 isNotEmpty ,
4847} from '../../shared/empty.util' ;
4948import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component' ;
50- import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model' ;
5149import { StartsWithType } from '../../shared/starts-with/starts-with-type' ;
5250import {
5351 BrowseByMetadataComponent ,
@@ -96,27 +94,23 @@ export class BrowseByDateComponent extends BrowseByMetadataComponent implements
9694 this . loading$ = of ( false ) ;
9795 return ;
9896 }
99- const sortConfig = new SortOptions ( 'default' , SortDirection . ASC ) ;
97+ this . browseId = this . route . snapshot . params . id ;
10098 this . startsWithType = StartsWithType . date ;
101- this . currentPagination$ = this . paginationService . getCurrentPagination ( this . paginationConfig . id , this . paginationConfig ) ;
102- this . currentSort$ = this . paginationService . getCurrentSort ( this . paginationConfig . id , sortConfig ) ;
103- const routeParams$ : Observable < Params > = observableCombineLatest ( [
104- this . route . params ,
105- this . route . queryParams ,
106- ] ) . pipe (
107- map ( ( [ params , queryParams ] : [ Params , Params ] ) => Object . assign ( { } , params , queryParams ) ) ,
108- distinctUntilChanged ( ( prev : Params , curr : Params ) => prev . id === curr . id && prev . startsWith === curr . startsWith ) ,
109- ) ;
99+
110100 this . subs . push (
111- observableCombineLatest ( [
112- routeParams$ ,
113- this . scope$ ,
114- this . currentPagination$ ,
115- this . currentSort$ ,
116- ] ) . subscribe ( ( [ params , scope , currentPage , currentSort ] : [ Params , string , PaginationComponentOptions , SortOptions ] ) => {
101+ this . browseService . getConfiguredSortDirection ( this . browseId , SortDirection . ASC ) . pipe (
102+ map ( ( sortDir ) => new SortOptions ( this . browseId , sortDir ) ) ,
103+ switchMap ( ( sortConfig ) => {
104+ this . currentPagination$ = this . paginationService . getCurrentPagination ( this . paginationConfig . id , this . paginationConfig ) ;
105+ this . currentSort$ = this . paginationService . getCurrentSort ( this . paginationConfig . id , sortConfig , false ) ;
106+ return observableCombineLatest ( [ this . route . params , this . route . queryParams , this . scope$ , this . route . data , this . currentPagination$ , this . currentSort$ ] ) . pipe (
107+ map ( ( [ routeParams , queryParams , scope , data , currentPage , currentSort ] ) => ( {
108+ params : Object . assign ( { } , routeParams , queryParams , data ) , scope, currentPage, currentSort,
109+ } ) ) ) ;
110+ } ) ) . subscribe ( ( { params, scope, currentPage, currentSort } ) => {
117111 const metadataKeys = params . browseDefinition ? params . browseDefinition . metadataKeys : this . defaultMetadataKeys ;
118- this . browseId = params . id ;
119112 this . startsWith = + params . startsWith || params . startsWith ;
113+ this . browseId = params . id ;
120114 const searchOptions = browseParamsToOptions ( params , scope , currentPage , currentSort , this . browseId , this . fetchThumbnails ) ;
121115 this . updatePageWithItems ( searchOptions , this . value , undefined ) ;
122116 this . updateStartsWithOptions ( this . browseId , metadataKeys , params . scope ) ;
0 commit comments