]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-trending.component.ts
Simplify client syndications
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-trending.component.ts
1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { immutableAssign } from '@app/shared/misc/utils'
4 import { NotificationsService } from 'angular2-notifications'
5 import { AuthService } from '../../core/auth'
6 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7 import { SortField } from '../../shared/video/sort-field.type'
8 import { VideoService } from '../../shared/video/video.service'
9
10 @Component({
11 selector: 'my-videos-trending',
12 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
13 templateUrl: '../../shared/video/abstract-video-list.html'
14 })
15 export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
16 titlePage = 'Trending'
17 currentRoute = '/videos/trending'
18 defaultSort: SortField = '-views'
19
20 constructor (protected router: Router,
21 protected route: ActivatedRoute,
22 protected notificationsService: NotificationsService,
23 protected authService: AuthService,
24 private videoService: VideoService) {
25 super()
26 }
27
28 ngOnInit () {
29 super.ngOnInit()
30
31 this.generateSyndicationList()
32 }
33
34 ngOnDestroy () {
35 super.ngOnDestroy()
36 }
37
38 getVideosObservable (page: number) {
39 const newPagination = immutableAssign(this.pagination, { currentPage: page })
40 return this.videoService.getVideos(newPagination, this.sort)
41 }
42
43 generateSyndicationList () {
44 this.syndicationItems = this.videoService.getVideoFeedUrls()
45 }
46 }