]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+search/search.component.ts
Add filter on search results
[github/Chocobozzz/PeerTube.git] / client / src / app / +search / search.component.ts
index fcf6ebbec77c40202159962b1580d4e2890a4f10..b9ec6dbccf8c431babbf127b851e8ef884d282e3 100644 (file)
@@ -47,10 +47,6 @@ export class SearchComponent implements OnInit, OnDestroy {
   private subActivatedRoute: Subscription
   private isInitialLoad = false // set to false to show the search filters on first arrival
 
-  private channelsPerPage = 2
-  private playlistsPerPage = 2
-  private videosPerPage = 10
-
   private hasMoreResults = true
   private isSearching = false
 
@@ -247,7 +243,6 @@ export class SearchComponent implements OnInit, OnDestroy {
   private resetPagination () {
     this.pagination.currentPage = 1
     this.pagination.totalItems = null
-    this.channelsPerPage = 2
 
     this.results = []
   }
@@ -272,7 +267,7 @@ export class SearchComponent implements OnInit, OnDestroy {
   private getVideosObs () {
     const params = {
       search: this.currentSearch,
-      componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.videosPerPage }),
+      componentPagination: immutableAssign(this.pagination, { itemsPerPage: 10 }),
       advancedSearch: this.advancedSearch
     }
 
@@ -288,7 +283,7 @@ export class SearchComponent implements OnInit, OnDestroy {
   private getVideoChannelObs () {
     const params = {
       search: this.currentSearch,
-      componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.channelsPerPage }),
+      componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.buildChannelsPerPage() }),
       advancedSearch: this.advancedSearch
     }
 
@@ -304,7 +299,7 @@ export class SearchComponent implements OnInit, OnDestroy {
   private getVideoPlaylistObs () {
     const params = {
       search: this.currentSearch,
-      componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.playlistsPerPage }),
+      componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.buildPlaylistsPerPage() }),
       advancedSearch: this.advancedSearch
     }
 
@@ -334,4 +329,16 @@ export class SearchComponent implements OnInit, OnDestroy {
 
     return undefined
   }
+
+  private buildChannelsPerPage () {
+    if (this.advancedSearch.resultType === 'channels') return 10
+
+    return 2
+  }
+
+  private buildPlaylistsPerPage () {
+    if (this.advancedSearch.resultType === 'playlists') return 10
+
+    return 2
+  }
 }