1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
4 import { HooksService } from '@app/core/plugins/hooks.service'
5 import { immutableAssign } from '@app/helpers'
6 import { VideoService } from '@app/shared/shared-main'
7 import { AbstractVideoList } from '@app/shared/shared-video-miniature'
8 import { VideoSortField } from '@shared/models'
11 selector: 'my-videos-trending',
12 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
15 export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
17 defaultSort: VideoSortField = '-trending'
19 useUserVideoPreferences = true
22 protected router: Router,
23 protected serverService: ServerService,
24 protected route: ActivatedRoute,
25 protected notifier: Notifier,
26 protected authService: AuthService,
27 protected userService: UserService,
28 protected screenService: ScreenService,
29 protected storageService: LocalStorageService,
30 private videoService: VideoService,
31 private hooks: HooksService
39 this.generateSyndicationList()
41 this.serverService.getConfig().subscribe(
43 const trendingDays = config.trending.videos.intervalDays
45 if (trendingDays === 1) {
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`
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`
60 getVideosObservable (page: number) {
61 const newPagination = immutableAssign(this.pagination, { currentPage: page })
63 videoPagination: newPagination,
65 categoryOneOf: this.categoryOneOf,
66 languageOneOf: this.languageOneOf,
67 nsfwPolicy: this.nsfwPolicy,
71 return this.hooks.wrapObsFun(
72 this.videoService.getVideos.bind(this.videoService),
75 'filter:api.trending-videos.videos.list.params',
76 'filter:api.trending-videos.videos.list.result'
80 generateSyndicationList () {
81 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)