]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Redirect to homepage on empty search
authorChocobozzz <me@florianbigard.com>
Tue, 27 Mar 2018 13:12:55 +0000 (15:12 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 27 Mar 2018 13:12:55 +0000 (15:12 +0200)
client/src/app/header/header.component.ts
client/src/app/videos/video-list/video-search.component.ts

index a903048f234188a15f04acabc846c5ce0e687a22..6b0ee67ffa9f365da729600d338146f0343742bb 100644 (file)
@@ -19,8 +19,6 @@ export class HeaderComponent implements OnInit {
   }
 
   doSearch () {
-    if (!this.searchValue) return
-
     this.router.navigate([ '/videos', 'search' ], {
       queryParams: { search: this.searchValue }
     })
index 788797a4cf6cfcaf9f10407ed32c3159f8792a94..67857a0a9cf9fc53a3c743ea3246324b2a7fad54 100644 (file)
@@ -1,5 +1,6 @@
 import { Component, OnDestroy, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
+import { RedirectService } from '@app/core'
 import { immutableAssign } from '@app/shared/misc/utils'
 import { NotificationsService } from 'angular2-notifications'
 import { Subscription } from 'rxjs/Subscription'
@@ -26,7 +27,9 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
                protected route: ActivatedRoute,
                protected notificationsService: NotificationsService,
                protected authService: AuthService,
-               private videoService: VideoService) {
+               private videoService: VideoService,
+               private redirectService: RedirectService
+  ) {
     super()
   }
 
@@ -36,7 +39,8 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
     this.subActivatedRoute = this.route.queryParams.subscribe(
       queryParams => {
         const querySearch = queryParams['search']
-        if (!querySearch || this.otherRouteParams.search === querySearch) return
+        if (!querySearch) return this.redirectService.redirectToHomepage()
+        if (this.otherRouteParams.search === querySearch) return
 
         this.otherRouteParams.search = querySearch
         this.reloadVideos()