diff options
Diffstat (limited to 'client/src/app/header')
-rw-r--r-- | client/src/app/header/header.component.ts | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/client/src/app/header/header.component.ts b/client/src/app/header/header.component.ts index 88cd652e2..c6e942e0e 100644 --- a/client/src/app/header/header.component.ts +++ b/client/src/app/header/header.component.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { filter, first, map, tap } from 'rxjs/operators' | 1 | import { filter, first, map, tap } from 'rxjs/operators' |
2 | import { Component, OnInit } from '@angular/core' | 2 | import { Component, OnInit } from '@angular/core' |
3 | import { NavigationEnd, Router } from '@angular/router' | 3 | import { ActivatedRoute, NavigationEnd, Params, Router } from '@angular/router' |
4 | import { getParameterByName } from '../shared/misc/utils' | 4 | import { getParameterByName } from '../shared/misc/utils' |
5 | import { AuthService } from '@app/core' | 5 | import { AuthService } from '@app/core' |
6 | import { of } from 'rxjs' | 6 | import { of } from 'rxjs' |
@@ -16,6 +16,7 @@ export class HeaderComponent implements OnInit { | |||
16 | 16 | ||
17 | constructor ( | 17 | constructor ( |
18 | private router: Router, | 18 | private router: Router, |
19 | private route: ActivatedRoute, | ||
19 | private auth: AuthService | 20 | private auth: AuthService |
20 | ) {} | 21 | ) {} |
21 | 22 | ||
@@ -29,18 +30,24 @@ export class HeaderComponent implements OnInit { | |||
29 | } | 30 | } |
30 | 31 | ||
31 | doSearch () { | 32 | doSearch () { |
32 | const queryParams: any = { | 33 | const queryParams: Params = {} |
33 | search: this.searchValue | 34 | |
35 | if (window.location.pathname === '/search' && this.route.snapshot.queryParams) { | ||
36 | Object.assign(queryParams, this.route.snapshot.queryParams) | ||
34 | } | 37 | } |
35 | 38 | ||
39 | Object.assign(queryParams, { search: this.searchValue }) | ||
40 | |||
36 | const o = this.auth.isLoggedIn() | 41 | const o = this.auth.isLoggedIn() |
37 | ? this.loadUserLanguages(queryParams) | 42 | ? this.loadUserLanguagesIfNeeded(queryParams) |
38 | : of(true) | 43 | : of(true) |
39 | 44 | ||
40 | o.subscribe(() => this.router.navigate([ '/search' ], { queryParams })) | 45 | o.subscribe(() => this.router.navigate([ '/search' ], { queryParams })) |
41 | } | 46 | } |
42 | 47 | ||
43 | private loadUserLanguages (queryParams: any) { | 48 | private loadUserLanguagesIfNeeded (queryParams: any) { |
49 | if (queryParams && queryParams.languageOneOf) return of(queryParams) | ||
50 | |||
44 | return this.auth.userInformationLoaded | 51 | return this.auth.userInformationLoaded |
45 | .pipe( | 52 | .pipe( |
46 | first(), | 53 | first(), |