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