]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-search/search.service.ts
Fix homepage
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-search / search.service.ts
index fdfab0e0e18aa3a253a0b679a12b5f5081615ed7..61acfb466cdcce52dfb5977c83a278d6a20278ab 100644 (file)
@@ -1,4 +1,4 @@
-import { Observable } from 'rxjs'
+import { Observable, of } from 'rxjs'
 import { catchError, map, switchMap } from 'rxjs/operators'
 import { HttpClient, HttpParams } from '@angular/common/http'
 import { Injectable } from '@angular/core'
@@ -39,11 +39,15 @@ export class SearchService {
   }): Observable<ResultList<Video>> {
     const { search, uuids, componentPagination, advancedSearch } = parameters
 
+    if (advancedSearch?.resultType !== undefined && advancedSearch.resultType !== 'videos') {
+      return of({ total: 0, data: [] })
+    }
+
     const url = SearchService.BASE_SEARCH_URL + 'videos'
     let pagination: RestPagination
 
     if (componentPagination) {
-      pagination = this.restService.componentPaginationToRestPagination(componentPagination)
+      pagination = this.restService.componentToRestPagination(componentPagination)
     }
 
     let params = new HttpParams()
@@ -73,11 +77,15 @@ export class SearchService {
   }): Observable<ResultList<VideoChannel>> {
     const { search, advancedSearch, componentPagination, handles } = parameters
 
+    if (advancedSearch?.resultType !== undefined && advancedSearch.resultType !== 'channels') {
+      return of({ total: 0, data: [] })
+    }
+
     const url = SearchService.BASE_SEARCH_URL + 'video-channels'
 
     let pagination: RestPagination
     if (componentPagination) {
-      pagination = this.restService.componentPaginationToRestPagination(componentPagination)
+      pagination = this.restService.componentToRestPagination(componentPagination)
     }
 
     let params = new HttpParams()
@@ -107,11 +115,15 @@ export class SearchService {
   }): Observable<ResultList<VideoPlaylist>> {
     const { search, advancedSearch, componentPagination, uuids } = parameters
 
+    if (advancedSearch?.resultType !== undefined && advancedSearch.resultType !== 'playlists') {
+      return of({ total: 0, data: [] })
+    }
+
     const url = SearchService.BASE_SEARCH_URL + 'video-playlists'
 
     let pagination: RestPagination
     if (componentPagination) {
-      pagination = this.restService.componentPaginationToRestPagination(componentPagination)
+      pagination = this.restService.componentToRestPagination(componentPagination)
     }
 
     let params = new HttpParams()