]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/video-list/video-trending.component.ts
Skip videos count on client if we don't use it
[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'
0cd4344f 3import { immutableAssign } from '@app/shared/misc/utils'
b2731bff 4import { AuthService } from '../../core/auth'
7bfd1b1e 5import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7b87d2d5 6import { VideoSortField } from '../../shared/video/sort-field.type'
f3aaa9a9 7import { VideoService } from '../../shared/video/video.service'
989e526a 8import { I18n } from '@ngx-translate/i18n-polyfill'
bbe0f064 9import { ScreenService } from '@app/shared/misc/screen.service'
9b4b15f9 10import { Notifier, ServerService } from '@app/core'
93cae479 11import { HooksService } from '@app/core/plugins/hooks.service'
9bf9d2a5
C
12
13@Component({
14 selector: 'my-videos-trending',
202f6b6c
C
15 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
16 templateUrl: '../../shared/video/abstract-video-list.html'
9bf9d2a5 17})
9af61e84 18export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
989e526a 19 titlePage: string
9a629c6e 20 defaultSort: VideoSortField = '-trending'
9bf9d2a5 21
3caf77d3
C
22 useUserVideoLanguagePreferences = true
23
989e526a 24 constructor (
34c7f429 25 protected i18n: I18n,
989e526a 26 protected router: Router,
489290b8 27 protected serverService: ServerService,
989e526a 28 protected route: ActivatedRoute,
f8b2c1b4 29 protected notifier: Notifier,
989e526a 30 protected authService: AuthService,
bbe0f064 31 protected screenService: ScreenService,
93cae479
C
32 private videoService: VideoService,
33 private hooks: HooksService
989e526a 34 ) {
9bf9d2a5
C
35 super()
36 }
37
38 ngOnInit () {
39 super.ngOnInit()
cc1561f9 40
244e76a5 41 this.generateSyndicationList()
7b95f313 42
ba430d75
C
43 this.serverService.getConfig().subscribe(
44 config => {
45 const trendingDays = config.trending.videos.intervalDays
7b95f313 46
572b8e02
C
47 if (trendingDays === 1) {
48 this.titlePage = this.i18n('Trending for the last 24 hours')
1aabcae7 49 this.titleTooltip = this.i18n('Trending videos are those totalizing the greatest number of views during the last 24 hours')
572b8e02
C
50 } else {
51 this.titlePage = this.i18n('Trending for the last {{days}} days', { days: trendingDays })
52 this.titleTooltip = this.i18n(
1aabcae7 53 'Trending videos are those totalizing the greatest number of views during the last {{days}} days',
572b8e02
C
54 { days: trendingDays }
55 )
56 }
57 })
9bf9d2a5
C
58 }
59
9af61e84
C
60 ngOnDestroy () {
61 super.ngOnDestroy()
62 }
63
0cd4344f
C
64 getVideosObservable (page: number) {
65 const newPagination = immutableAssign(this.pagination, { currentPage: page })
93cae479 66 const params = {
3caf77d3
C
67 videoPagination: newPagination,
68 sort: this.sort,
3caf77d3 69 categoryOneOf: this.categoryOneOf,
440d39c5
C
70 languageOneOf: this.languageOneOf,
71 skipCount: true
93cae479
C
72 }
73
74 return this.hooks.wrapObsFun(
75 this.videoService.getVideos.bind(this.videoService),
76 params,
77 'common',
7663e55a
C
78 'filter:api.trending-videos.videos.list.params',
79 'filter:api.trending-videos.videos.list.result'
93cae479 80 )
9bf9d2a5 81 }
244e76a5
RK
82
83 generateSyndicationList () {
d59cba29 84 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
244e76a5 85 }
9bf9d2a5 86}