mirror of https://github.com/Chocobozzz/PeerTube
Fix search pagination
parent
e8395f027b
commit
c88593f72f
|
@ -10,7 +10,7 @@ import { Video } from './video.model'
|
|||
export abstract class AbstractVideoList implements OnInit {
|
||||
pagination: ComponentPagination = {
|
||||
currentPage: 1,
|
||||
itemsPerPage: 25,
|
||||
itemsPerPage: 10,
|
||||
totalItems: null
|
||||
}
|
||||
sort: SortField = '-createdAt'
|
||||
|
@ -26,6 +26,9 @@ export abstract class AbstractVideoList implements OnInit {
|
|||
protected abstract currentRoute: string
|
||||
|
||||
abstract titlePage: string
|
||||
|
||||
protected otherParams = {}
|
||||
|
||||
private loadedPages: { [ id: number ]: boolean } = {}
|
||||
|
||||
abstract getVideosObservable (): Observable<{ videos: Video[], totalVideos: number}>
|
||||
|
@ -119,7 +122,7 @@ export abstract class AbstractVideoList implements OnInit {
|
|||
page: this.pagination.currentPage
|
||||
}
|
||||
|
||||
return params
|
||||
return Object.assign(params, this.otherParams)
|
||||
}
|
||||
|
||||
protected loadRouteParams (routeParams: { [ key: string ]: any }) {
|
||||
|
|
|
@ -16,7 +16,9 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
|
|||
currentRoute = '/videos/search'
|
||||
loadOnInit = false
|
||||
|
||||
private search = ''
|
||||
protected otherParams = {
|
||||
search: ''
|
||||
}
|
||||
private subActivatedRoute: Subscription
|
||||
|
||||
constructor (protected router: Router,
|
||||
|
@ -32,7 +34,10 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
|
|||
|
||||
this.subActivatedRoute = this.route.queryParams.subscribe(
|
||||
queryParams => {
|
||||
this.search = queryParams['search']
|
||||
const querySearch = queryParams['search']
|
||||
if (!querySearch || this.otherParams.search === querySearch) return
|
||||
|
||||
this.otherParams.search = querySearch
|
||||
this.reloadVideos()
|
||||
},
|
||||
|
||||
|
@ -47,6 +52,6 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
|
|||
}
|
||||
|
||||
getVideosObservable () {
|
||||
return this.videoService.searchVideos(this.search, this.pagination, this.sort)
|
||||
return this.videoService.searchVideos(this.otherParams.search, this.pagination, this.sort)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue