diff options
author | Chocobozzz <me@florianbigard.com> | 2018-03-27 15:12:55 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-03-27 15:12:55 +0200 |
commit | fc62e39c0b5d20b19916b2880a0f9a110fcc02e5 (patch) | |
tree | 185b339940f557b4181b6017b8700ceb236413d2 /client/src/app | |
parent | 3e0c9ff5d5d2a2435fcc25deac3a98223aa7c225 (diff) | |
download | PeerTube-fc62e39c0b5d20b19916b2880a0f9a110fcc02e5.tar.gz PeerTube-fc62e39c0b5d20b19916b2880a0f9a110fcc02e5.tar.zst PeerTube-fc62e39c0b5d20b19916b2880a0f9a110fcc02e5.zip |
Redirect to homepage on empty search
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/header/header.component.ts | 2 | ||||
-rw-r--r-- | client/src/app/videos/video-list/video-search.component.ts | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/client/src/app/header/header.component.ts b/client/src/app/header/header.component.ts index a903048f2..6b0ee67ff 100644 --- a/client/src/app/header/header.component.ts +++ b/client/src/app/header/header.component.ts | |||
@@ -19,8 +19,6 @@ export class HeaderComponent implements OnInit { | |||
19 | } | 19 | } |
20 | 20 | ||
21 | doSearch () { | 21 | doSearch () { |
22 | if (!this.searchValue) return | ||
23 | |||
24 | this.router.navigate([ '/videos', 'search' ], { | 22 | this.router.navigate([ '/videos', 'search' ], { |
25 | queryParams: { search: this.searchValue } | 23 | queryParams: { search: this.searchValue } |
26 | }) | 24 | }) |
diff --git a/client/src/app/videos/video-list/video-search.component.ts b/client/src/app/videos/video-list/video-search.component.ts index 788797a4c..67857a0a9 100644 --- a/client/src/app/videos/video-list/video-search.component.ts +++ b/client/src/app/videos/video-list/video-search.component.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { RedirectService } from '@app/core' | ||
3 | import { immutableAssign } from '@app/shared/misc/utils' | 4 | import { immutableAssign } from '@app/shared/misc/utils' |
4 | import { NotificationsService } from 'angular2-notifications' | 5 | import { NotificationsService } from 'angular2-notifications' |
5 | import { Subscription } from 'rxjs/Subscription' | 6 | import { Subscription } from 'rxjs/Subscription' |
@@ -26,7 +27,9 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O | |||
26 | protected route: ActivatedRoute, | 27 | protected route: ActivatedRoute, |
27 | protected notificationsService: NotificationsService, | 28 | protected notificationsService: NotificationsService, |
28 | protected authService: AuthService, | 29 | protected authService: AuthService, |
29 | private videoService: VideoService) { | 30 | private videoService: VideoService, |
31 | private redirectService: RedirectService | ||
32 | ) { | ||
30 | super() | 33 | super() |
31 | } | 34 | } |
32 | 35 | ||
@@ -36,7 +39,8 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O | |||
36 | this.subActivatedRoute = this.route.queryParams.subscribe( | 39 | this.subActivatedRoute = this.route.queryParams.subscribe( |
37 | queryParams => { | 40 | queryParams => { |
38 | const querySearch = queryParams['search'] | 41 | const querySearch = queryParams['search'] |
39 | if (!querySearch || this.otherRouteParams.search === querySearch) return | 42 | if (!querySearch) return this.redirectService.redirectToHomepage() |
43 | if (this.otherRouteParams.search === querySearch) return | ||
40 | 44 | ||
41 | this.otherRouteParams.search = querySearch | 45 | this.otherRouteParams.search = querySearch |
42 | this.reloadVideos() | 46 | this.reloadVideos() |