]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/video-list/video-trending.component.ts
Rewrite infinite scroll
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-trending.component.ts
index b97966c12b36c6208d9d2986c427dbcb486297ea..a42457273125d8c790086767d338d4436dbde9c3 100644 (file)
@@ -1,20 +1,26 @@
-import { Component, OnDestroy, OnInit } from '@angular/core'
+import { Component, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
+import { immutableAssign } from '@app/shared/misc/utils'
 import { NotificationsService } from 'angular2-notifications'
-import { VideoService } from '../shared'
-import { AbstractVideoList } from './shared'
+import { AuthService } from '../../core/auth'
+import { AbstractVideoList } from '../../shared/video/abstract-video-list'
+import { SortField } from '../../shared/video/sort-field.type'
+import { VideoService } from '../../shared/video/video.service'
 
 @Component({
   selector: 'my-videos-trending',
-  styleUrls: [ './shared/abstract-video-list.scss' ],
-  templateUrl: './shared/abstract-video-list.html'
+  styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
+  templateUrl: '../../shared/video/abstract-video-list.html'
 })
-export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
+export class VideoTrendingComponent extends AbstractVideoList implements OnInit {
   titlePage = 'Trending'
+  currentRoute = '/videos/trending'
+  defaultSort: SortField = '-views'
 
   constructor (protected router: Router,
                protected route: ActivatedRoute,
                protected notificationsService: NotificationsService,
+               protected authService: AuthService,
                private videoService: VideoService) {
     super()
   }
@@ -23,11 +29,8 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
     super.ngOnInit()
   }
 
-  ngOnDestroy () {
-    super.ngOnDestroy()
-  }
-
-  getVideosObservable () {
-    return this.videoService.getVideos(this.pagination, this.sort)
+  getVideosObservable (page: number) {
+    const newPagination = immutableAssign(this.pagination, { currentPage: page })
+    return this.videoService.getVideos(newPagination, this.sort)
   }
 }