From fc62e39c0b5d20b19916b2880a0f9a110fcc02e5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 27 Mar 2018 15:12:55 +0200 Subject: Redirect to homepage on empty search --- client/src/app/videos/video-list/video-search.component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'client/src/app/videos/video-list/video-search.component.ts') 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 @@ 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() -- cgit v1.2.3