]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+videos/video-list/video-trending.component.ts
Fix rss feed with HLS videos
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / video-list / video-trending.component.ts
CommitLineData
9af61e84 1import { Component, OnDestroy, OnInit } from '@angular/core'
9bf9d2a5 2import { ActivatedRoute, Router } from '@angular/router'
67ed6552 3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
93cae479 4import { HooksService } from '@app/core/plugins/hooks.service'
67ed6552
C
5import { immutableAssign } from '@app/helpers'
6import { VideoService } from '@app/shared/shared-main'
7import { AbstractVideoList } from '@app/shared/shared-video-miniature'
67ed6552 8import { VideoSortField } from '@shared/models'
9bf9d2a5
C
9
10@Component({
11 selector: 'my-videos-trending',
67ed6552
C
12 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
9bf9d2a5 14})
9af61e84 15export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
989e526a 16 titlePage: string
9a629c6e 17 defaultSort: VideoSortField = '-trending'
9bf9d2a5 18
5c20a455 19 useUserVideoPreferences = true
3caf77d3 20
989e526a
C
21 constructor (
22 protected router: Router,
489290b8 23 protected serverService: ServerService,
989e526a 24 protected route: ActivatedRoute,
f8b2c1b4 25 protected notifier: Notifier,
989e526a 26 protected authService: AuthService,
d3217560 27 protected userService: UserService,
bbe0f064 28 protected screenService: ScreenService,
d3217560 29 protected storageService: LocalStorageService,
93cae479
C
30 private videoService: VideoService,
31 private hooks: HooksService
989e526a 32 ) {
9bf9d2a5
C
33 super()
34 }
35
36 ngOnInit () {
37 super.ngOnInit()
cc1561f9 38
244e76a5 39 this.generateSyndicationList()
7b95f313 40
ba430d75
C
41 this.serverService.getConfig().subscribe(
42 config => {
43 const trendingDays = config.trending.videos.intervalDays
7b95f313 44
572b8e02 45 if (trendingDays === 1) {
66357162
C
46 this.titlePage = $localize`Trending for the last 24 hours`
47 this.titleTooltip = $localize`Trending videos are those totalizing the greatest number of views during the last 24 hours`
f19a9e4b 48 return
572b8e02 49 }
f19a9e4b
C
50
51 this.titlePage = $localize`Trending for the last ${trendingDays} days`
52 this.titleTooltip = $localize`Trending videos are those totalizing the greatest number of views during the last ${trendingDays} days`
572b8e02 53 })
9bf9d2a5
C
54 }
55
9af61e84
C
56 ngOnDestroy () {
57 super.ngOnDestroy()
58 }
59
0cd4344f
C
60 getVideosObservable (page: number) {
61 const newPagination = immutableAssign(this.pagination, { currentPage: page })
93cae479 62 const params = {
3caf77d3
C
63 videoPagination: newPagination,
64 sort: this.sort,
3caf77d3 65 categoryOneOf: this.categoryOneOf,
440d39c5 66 languageOneOf: this.languageOneOf,
5c20a455 67 nsfwPolicy: this.nsfwPolicy,
440d39c5 68 skipCount: true
93cae479
C
69 }
70
71 return this.hooks.wrapObsFun(
72 this.videoService.getVideos.bind(this.videoService),
73 params,
74 'common',
7663e55a
C
75 'filter:api.trending-videos.videos.list.params',
76 'filter:api.trending-videos.videos.list.result'
93cae479 77 )
9bf9d2a5 78 }
244e76a5
RK
79
80 generateSyndicationList () {
d59cba29 81 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
244e76a5 82 }
9bf9d2a5 83}