export abstract class AbstractVideoList implements OnInit {
pagination: ComponentPagination = {
currentPage: 1,
- itemsPerPage: 25,
+ itemsPerPage: 10,
totalItems: null
}
sort: SortField = '-createdAt'
protected abstract currentRoute: string
abstract titlePage: string
+
+ protected otherParams = {}
+
private loadedPages: { [ id: number ]: boolean } = {}
abstract getVideosObservable (): Observable<{ videos: Video[], totalVideos: number}>
page: this.pagination.currentPage
}
- return params
+ return Object.assign(params, this.otherParams)
}
protected loadRouteParams (routeParams: { [ key: string ]: any }) {
currentRoute = '/videos/search'
loadOnInit = false
- private search = ''
+ protected otherParams = {
+ search: ''
+ }
private subActivatedRoute: Subscription
constructor (protected router: Router,
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()
},
}
getVideosObservable () {
- return this.videoService.searchVideos(this.search, this.pagination, this.sort)
+ return this.videoService.searchVideos(this.otherParams.search, this.pagination, this.sort)
}
}