aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-29 09:30:06 +0100
committerChocobozzz <me@florianbigard.com>2018-01-29 09:30:06 +0100
commitc88593f72f1097cc34a091b4cb4b6d6e214d1e9f (patch)
tree23c78f45ac3029bf8e3cf224f1f8cf9e27a3e944 /client
parente8395f027b6c3e3f757c740e35b20e76c51b03bd (diff)
downloadPeerTube-c88593f72f1097cc34a091b4cb4b6d6e214d1e9f.tar.gz
PeerTube-c88593f72f1097cc34a091b4cb4b6d6e214d1e9f.tar.zst
PeerTube-c88593f72f1097cc34a091b4cb4b6d6e214d1e9f.zip
Fix search pagination
Diffstat (limited to 'client')
-rw-r--r--client/src/app/shared/video/abstract-video-list.ts7
-rw-r--r--client/src/app/videos/video-list/video-search.component.ts11
2 files changed, 13 insertions, 5 deletions
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts
index 354373776..aaf376c81 100644
--- a/client/src/app/shared/video/abstract-video-list.ts
+++ b/client/src/app/shared/video/abstract-video-list.ts
@@ -10,7 +10,7 @@ import { Video } from './video.model'
10export abstract class AbstractVideoList implements OnInit { 10export abstract class AbstractVideoList implements OnInit {
11 pagination: ComponentPagination = { 11 pagination: ComponentPagination = {
12 currentPage: 1, 12 currentPage: 1,
13 itemsPerPage: 25, 13 itemsPerPage: 10,
14 totalItems: null 14 totalItems: null
15 } 15 }
16 sort: SortField = '-createdAt' 16 sort: SortField = '-createdAt'
@@ -26,6 +26,9 @@ export abstract class AbstractVideoList implements OnInit {
26 protected abstract currentRoute: string 26 protected abstract currentRoute: string
27 27
28 abstract titlePage: string 28 abstract titlePage: string
29
30 protected otherParams = {}
31
29 private loadedPages: { [ id: number ]: boolean } = {} 32 private loadedPages: { [ id: number ]: boolean } = {}
30 33
31 abstract getVideosObservable (): Observable<{ videos: Video[], totalVideos: number}> 34 abstract getVideosObservable (): Observable<{ videos: Video[], totalVideos: number}>
@@ -119,7 +122,7 @@ export abstract class AbstractVideoList implements OnInit {
119 page: this.pagination.currentPage 122 page: this.pagination.currentPage
120 } 123 }
121 124
122 return params 125 return Object.assign(params, this.otherParams)
123 } 126 }
124 127
125 protected loadRouteParams (routeParams: { [ key: string ]: any }) { 128 protected loadRouteParams (routeParams: { [ key: string ]: any }) {
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 b7556c13e..67726afdc 100644
--- a/client/src/app/videos/video-list/video-search.component.ts
+++ b/client/src/app/videos/video-list/video-search.component.ts
@@ -16,7 +16,9 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
16 currentRoute = '/videos/search' 16 currentRoute = '/videos/search'
17 loadOnInit = false 17 loadOnInit = false
18 18
19 private search = '' 19 protected otherParams = {
20 search: ''
21 }
20 private subActivatedRoute: Subscription 22 private subActivatedRoute: Subscription
21 23
22 constructor (protected router: Router, 24 constructor (protected router: Router,
@@ -32,7 +34,10 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
32 34
33 this.subActivatedRoute = this.route.queryParams.subscribe( 35 this.subActivatedRoute = this.route.queryParams.subscribe(
34 queryParams => { 36 queryParams => {
35 this.search = queryParams['search'] 37 const querySearch = queryParams['search']
38 if (!querySearch || this.otherParams.search === querySearch) return
39
40 this.otherParams.search = querySearch
36 this.reloadVideos() 41 this.reloadVideos()
37 }, 42 },
38 43
@@ -47,6 +52,6 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
47 } 52 }
48 53
49 getVideosObservable () { 54 getVideosObservable () {
50 return this.videoService.searchVideos(this.search, this.pagination, this.sort) 55 return this.videoService.searchVideos(this.otherParams.search, this.pagination, this.sort)
51 } 56 }
52} 57}