77
88// Core dependencies
99import { Component , OnDestroy , OnInit , Renderer2 } from "@angular/core" ;
10- import { Location } from "@angular/common" ;
11- import * as _ from "lodash" ;
1210import { DeviceDetectorService } from "ngx-device-detector" ;
1311import { select , Store } from "@ngrx/store" ;
1412import { combineLatest , Observable , Subject } from "rxjs" ;
15- import { distinctUntilChanged , map , takeUntil } from "rxjs/operators" ;
13+ import { map , takeUntil } from "rxjs/operators" ;
1614
1715// App dependencies
1816import { FilesState } from "./files.state" ;
@@ -21,16 +19,15 @@ import { selectFacetFacets } from "./_ngrx/facet/facet.selectors";
2119import {
2220 selectFileSummary ,
2321 selectEntities ,
24- selectSelectedEntity
22+ selectSelectedEntitySpec
2523} from "./_ngrx/file.selectors" ;
2624import {
2725 selectSearchTerms ,
2826 selectSelectedProjectSearchTerms ,
29- selectSelectedSearchTerms , selectSelectedSearchTermsBySearchKey
27+ selectSelectedSearchTerms
3028} from "./_ngrx/search/search.selectors" ;
3129import { EntitySelectAction } from "./_ngrx/table/table.actions" ;
3230import { SearchTerm } from "./search/search-term.model" ;
33- import { SearchTermUrlService } from "./search/url/search-term-url.service" ;
3431import EntitySpec from "./shared/entity-spec" ;
3532
3633@Component ( {
@@ -48,14 +45,10 @@ export class FilesComponent implements OnInit, OnDestroy {
4845
4946 /**
5047 * @param {DeviceDetectorService } deviceService
51- * @param {SearchTermUrlService } locationService
52- * @param {Location } location
5348 * @param {Store<AppState> } store
5449 * @param {Renderer2 } renderer
5550 */
5651 constructor ( private deviceService : DeviceDetectorService ,
57- private locationService : SearchTermUrlService ,
58- private location : Location ,
5952 private store : Store < AppState > ,
6053 private renderer : Renderer2 ) {
6154 }
@@ -99,35 +92,6 @@ export class FilesComponent implements OnInit, OnDestroy {
9992 this . store . dispatch ( new EntitySelectAction ( tab . key ) ) ;
10093 }
10194
102- /**
103- * Update URL on change of selected facets.
104- */
105- private initOnStateChanges ( ) {
106-
107- // Set up the URL state management - write to the browser address bar when the selected facets change.
108- combineLatest (
109- this . store . pipe ( select ( selectSelectedEntity ) ) ,
110- this . store . pipe ( select ( selectSelectedSearchTermsBySearchKey ) )
111- )
112- . pipe (
113- takeUntil ( this . ngDestroy$ ) ,
114- distinctUntilChanged ( ( previous , current ) => {
115- return _ . isEqual ( previous , current ) ;
116- } )
117- )
118- . subscribe ( ( [ selectedEntity , selectedSearchTermsBySearchKey ] ) => {
119-
120- const filterQueryString = this . locationService . stringifySearchTerms ( selectedSearchTermsBySearchKey ) ;
121-
122- const path = selectedEntity . key ;
123- const params = new URLSearchParams ( ) ;
124- if ( ! ! filterQueryString ) {
125- params . set ( "filter" , filterQueryString ) ;
126- }
127- this . location . replaceState ( path , params . toString ( ) ) ;
128- } ) ;
129- }
130-
13195 /**
13296 * Setup initial component state from store.
13397 */
@@ -137,7 +101,7 @@ export class FilesComponent implements OnInit, OnDestroy {
137101 this . store . pipe ( select ( selectFileSummary ) ) , // Counts
138102 this . store . pipe ( select ( selectFacetFacets ) ) , // Complete list of facets to display - both file facets (facets with term lists) as well as range facets
139103 this . store . pipe ( select ( selectEntities ) ) , // Set of tabs to be displayed
140- this . store . pipe ( select ( selectSelectedEntity ) ) , // Current selected tab
104+ this . store . pipe ( select ( selectSelectedEntitySpec ) ) , // Current selected tab
141105 this . store . pipe ( select ( selectSelectedSearchTerms ) ) , // Set of possible search terms, used to populate the search autosuggest.
142106 this . store . pipe ( select ( selectSearchTerms ) ) ,
143107 this . store . pipe ( // Current set of selected projects, if any
@@ -196,6 +160,5 @@ export class FilesComponent implements OnInit, OnDestroy {
196160 public ngOnInit ( ) {
197161
198162 this . initState ( ) ;
199- this . initOnStateChanges ( ) ;
200163 }
201164}
0 commit comments