aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/header/header.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/header/header.component.ts')
-rw-r--r--client/src/app/header/header.component.ts29
1 files changed, 24 insertions, 5 deletions
diff --git a/client/src/app/header/header.component.ts b/client/src/app/header/header.component.ts
index f73d40947..88cd652e2 100644
--- a/client/src/app/header/header.component.ts
+++ b/client/src/app/header/header.component.ts
@@ -1,7 +1,9 @@
1import { filter, map } from 'rxjs/operators' 1import { filter, first, map, tap } from 'rxjs/operators'
2import { Component, OnInit } from '@angular/core' 2import { Component, OnInit } from '@angular/core'
3import { NavigationEnd, Router } from '@angular/router' 3import { NavigationEnd, Router } from '@angular/router'
4import { getParameterByName } from '../shared/misc/utils' 4import { getParameterByName } from '../shared/misc/utils'
5import { AuthService } from '@app/core'
6import { of } from 'rxjs'
5 7
6@Component({ 8@Component({
7 selector: 'my-header', 9 selector: 'my-header',
@@ -12,7 +14,10 @@ import { getParameterByName } from '../shared/misc/utils'
12export class HeaderComponent implements OnInit { 14export class HeaderComponent implements OnInit {
13 searchValue = '' 15 searchValue = ''
14 16
15 constructor (private router: Router) {} 17 constructor (
18 private router: Router,
19 private auth: AuthService
20 ) {}
16 21
17 ngOnInit () { 22 ngOnInit () {
18 this.router.events 23 this.router.events
@@ -24,8 +29,22 @@ export class HeaderComponent implements OnInit {
24 } 29 }
25 30
26 doSearch () { 31 doSearch () {
27 this.router.navigate([ '/search' ], { 32 const queryParams: any = {
28 queryParams: { search: this.searchValue } 33 search: this.searchValue
29 }) 34 }
35
36 const o = this.auth.isLoggedIn()
37 ? this.loadUserLanguages(queryParams)
38 : of(true)
39
40 o.subscribe(() => this.router.navigate([ '/search' ], { queryParams }))
41 }
42
43 private loadUserLanguages (queryParams: any) {
44 return this.auth.userInformationLoaded
45 .pipe(
46 first(),
47 tap(() => Object.assign(queryParams, { languageOneOf: this.auth.getUser().videoLanguages }))
48 )
30 } 49 }
31} 50}