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 { AuthService } from '../../core/auth'
5 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
6 import { VideoSortField } from '../../shared/video/sort-field.type'
7 import { VideoService } from '../../shared/video/video.service'
8 import { I18n } from '@ngx-translate/i18n-polyfill'
9 import { ScreenService } from '@app/shared/misc/screen.service'
10 import { Notifier, ServerService } from '@app/core'
11 import { HooksService } from '@app/core/plugins/hooks.service'
14 selector: 'my-videos-trending',
15 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
16 templateUrl: '../../shared/video/abstract-video-list.html'
18 export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
20 defaultSort: VideoSortField = '-trending'
22 useUserVideoLanguagePreferences = true
26 protected router: Router,
27 protected serverService: ServerService,
28 protected route: ActivatedRoute,
29 protected notifier: Notifier,
30 protected authService: AuthService,
31 protected screenService: ScreenService,
32 private videoService: VideoService,
33 private hooks: HooksService
41 this.generateSyndicationList()
43 this.serverService.configLoaded.subscribe(
45 const trendingDays = this.serverService.getConfig().trending.videos.intervalDays
47 if (trendingDays === 1) {
48 this.titlePage = this.i18n('Trending for the last 24 hours')
49 this.titleTooltip = this.i18n('Trending videos are those totalizing the greatest number of views during the last 24 hours')
51 this.titlePage = this.i18n('Trending for the last {{days}} days', { days: trendingDays })
52 this.titleTooltip = this.i18n(
53 'Trending videos are those totalizing the greatest number of views during the last {{days}} days',
54 { days: trendingDays }
64 getVideosObservable (page: number) {
65 const newPagination = immutableAssign(this.pagination, { currentPage: page })
67 videoPagination: newPagination,
69 categoryOneOf: this.categoryOneOf,
70 languageOneOf: this.languageOneOf
73 return this.hooks.wrapObsFun(
74 this.videoService.getVideos.bind(this.videoService),
77 'filter:api.trending-videos.videos.list.params',
78 'filter:api.trending-videos.videos.list.result'
82 generateSyndicationList () {
83 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)