aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-06-19 15:34:47 +0200
committerChocobozzz <me@florianbigard.com>2019-06-19 15:34:47 +0200
commita5f8b0b49f09e4399a8176d5cd06cc80c61b07d8 (patch)
treef6a33082c2df4e4f60185db83f8140b5b7b338a7 /client/src/app
parentee1d0dfb6d179d8742b6a3eb6ffce6a08fb16c9f (diff)
downloadPeerTube-a5f8b0b49f09e4399a8176d5cd06cc80c61b07d8.tar.gz
PeerTube-a5f8b0b49f09e4399a8176d5cd06cc80c61b07d8.tar.zst
PeerTube-a5f8b0b49f09e4399a8176d5cd06cc80c61b07d8.zip
Add language filter in header search
Diffstat (limited to 'client/src/app')
-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}