diff options
author | Chocobozzz <me@florianbigard.com> | 2019-10-21 13:31:58 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-10-21 13:31:58 +0200 |
commit | baeb429d06d101f69c677fdb70c3da2eb9d3823d (patch) | |
tree | c5bf70c96cb4eaf4f1cc8c32e4df88c7f4a132bb /client | |
parent | f1b38883922fd59b36f093e44a5091e090d20862 (diff) | |
download | PeerTube-baeb429d06d101f69c677fdb70c3da2eb9d3823d.tar.gz PeerTube-baeb429d06d101f69c677fdb70c3da2eb9d3823d.tar.zst PeerTube-baeb429d06d101f69c677fdb70c3da2eb9d3823d.zip |
Fix search with account video languages
Diffstat (limited to 'client')
-rw-r--r-- | client/src/app/header/header.component.ts | 17 | ||||
-rw-r--r-- | client/src/app/search/advanced-search.model.ts | 1 | ||||
-rw-r--r-- | client/src/app/search/search-filters.component.ts | 6 | ||||
-rw-r--r-- | client/src/app/search/search.component.ts | 4 |
4 files changed, 17 insertions, 11 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(), |
diff --git a/client/src/app/search/advanced-search.model.ts b/client/src/app/search/advanced-search.model.ts index 5b713e145..e2a0253f4 100644 --- a/client/src/app/search/advanced-search.model.ts +++ b/client/src/app/search/advanced-search.model.ts | |||
@@ -139,6 +139,7 @@ export class AdvancedSearch { | |||
139 | 139 | ||
140 | private intoArray (value: any) { | 140 | private intoArray (value: any) { |
141 | if (!value) return undefined | 141 | if (!value) return undefined |
142 | if (Array.isArray(value)) return value | ||
142 | 143 | ||
143 | if (typeof value === 'string') return value.split(',') | 144 | if (typeof value === 'string') return value.split(',') |
144 | 145 | ||
diff --git a/client/src/app/search/search-filters.component.ts b/client/src/app/search/search-filters.component.ts index e13aa91bf..14a05b721 100644 --- a/client/src/app/search/search-filters.component.ts +++ b/client/src/app/search/search-filters.component.ts | |||
@@ -83,9 +83,9 @@ export class SearchFiltersComponent implements OnInit { | |||
83 | } | 83 | } |
84 | 84 | ||
85 | ngOnInit () { | 85 | ngOnInit () { |
86 | this.videoCategories = this.serverService.getVideoCategories() | 86 | this.serverService.videoCategoriesLoaded.subscribe(() => this.videoCategories = this.serverService.getVideoCategories()) |
87 | this.videoLicences = this.serverService.getVideoLicences() | 87 | this.serverService.videoLicencesLoaded.subscribe(() => this.videoLicences = this.serverService.getVideoLicences()) |
88 | this.videoLanguages = this.serverService.getVideoLanguages() | 88 | this.serverService.videoLanguagesLoaded.subscribe(() => this.videoLanguages = this.serverService.getVideoLanguages()) |
89 | 89 | ||
90 | this.loadFromDurationRange() | 90 | this.loadFromDurationRange() |
91 | this.loadFromPublishedRange() | 91 | this.loadFromPublishedRange() |
diff --git a/client/src/app/search/search.component.ts b/client/src/app/search/search.component.ts index 5c4bb9379..202b97ab3 100644 --- a/client/src/app/search/search.component.ts +++ b/client/src/app/search/search.component.ts | |||
@@ -11,7 +11,6 @@ import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | |||
11 | import { immutableAssign } from '@app/shared/misc/utils' | 11 | import { immutableAssign } from '@app/shared/misc/utils' |
12 | import { Video } from '@app/shared/video/video.model' | 12 | import { Video } from '@app/shared/video/video.model' |
13 | import { HooksService } from '@app/core/plugins/hooks.service' | 13 | import { HooksService } from '@app/core/plugins/hooks.service' |
14 | import { PluginService } from '@app/core/plugins/plugin.service' | ||
15 | 14 | ||
16 | @Component({ | 15 | @Component({ |
17 | selector: 'my-search', | 16 | selector: 'my-search', |
@@ -44,8 +43,7 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
44 | private notifier: Notifier, | 43 | private notifier: Notifier, |
45 | private searchService: SearchService, | 44 | private searchService: SearchService, |
46 | private authService: AuthService, | 45 | private authService: AuthService, |
47 | private hooks: HooksService, | 46 | private hooks: HooksService |
48 | private pluginService: PluginService | ||
49 | ) { } | 47 | ) { } |
50 | 48 | ||
51 | get user () { | 49 | get user () { |