]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Client: navigate to /videos/list when do search on another page
authorChocobozzz <florian.bigard@gmail.com>
Sun, 21 Aug 2016 09:21:45 +0000 (11:21 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Sun, 21 Aug 2016 09:21:45 +0000 (11:21 +0200)
client/src/app/shared/search/search.component.ts
client/src/app/shared/search/search.service.ts

index 219997e85b5a29388a3c2510c13e7abaf8d4883b..853f5dc7c2cab121aac6a51d678db5d8204b5ede 100644 (file)
@@ -1,4 +1,5 @@
 import { Component, OnInit } from '@angular/core';
+import { Router } from '@angular/router';
 
 import { DROPDOWN_DIRECTIVES} from  'ng2-bootstrap/components/dropdown';
 
@@ -25,7 +26,7 @@ export class SearchComponent implements OnInit {
     value: ''
   };
 
-  constructor(private searchService: SearchService) {}
+  constructor(private searchService: SearchService, private router: Router) {}
 
   ngOnInit() {
     // Subscribe if the search changed
@@ -58,6 +59,10 @@ export class SearchComponent implements OnInit {
   }
 
   doSearch() {
+    if (this.router.url.indexOf('/videos/list') === -1) {
+      this.router.navigate([ '/videos/list' ]);
+    }
+
     this.searchService.searchUpdated.next(this.searchCriterias);
   }
 
index c7993db3dd05df9ba299dbb372e3300a0d398f42..717a7fa500e044fecc9bdce2d0aa0440196220eb 100644 (file)
@@ -1,5 +1,6 @@
 import { Injectable } from '@angular/core';
 import { Subject } from 'rxjs/Subject';
+import { ReplaySubject } from 'rxjs/ReplaySubject';
 
 import { Search } from './search.model';
 
@@ -12,6 +13,6 @@ export class SearchService {
 
   constructor() {
     this.updateSearch = new Subject<Search>();
-    this.searchUpdated = new Subject<Search>();
+    this.searchUpdated = new ReplaySubject<Search>(1);
   }
 }