aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/video-list/trending/video-trending.component.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2021-01-26 01:53:13 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-01-28 15:55:34 +0100
commit3da68f0a781ebd893521e2e6fa200280c92ae815 (patch)
tree11bddf841118703c725a96851318603407fd581d /client/src/app/+videos/video-list/trending/video-trending.component.ts
parent28eeb811c40325a28208231324f66f4032e5cf67 (diff)
downloadPeerTube-3da68f0a781ebd893521e2e6fa200280c92ae815.tar.gz
PeerTube-3da68f0a781ebd893521e2e6fa200280c92ae815.tar.zst
PeerTube-3da68f0a781ebd893521e2e6fa200280c92ae815.zip
add default trending page choice, revert comments count for hot strategy
Diffstat (limited to 'client/src/app/+videos/video-list/trending/video-trending.component.ts')
-rw-r--r--client/src/app/+videos/video-list/trending/video-trending.component.ts99
1 files changed, 0 insertions, 99 deletions
diff --git a/client/src/app/+videos/video-list/trending/video-trending.component.ts b/client/src/app/+videos/video-list/trending/video-trending.component.ts
deleted file mode 100644
index e77231586..000000000
--- a/client/src/app/+videos/video-list/trending/video-trending.component.ts
+++ /dev/null
@@ -1,99 +0,0 @@
1import { Component, ComponentFactoryResolver, Injector, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
4import { HooksService } from '@app/core/plugins/hooks.service'
5import { immutableAssign } from '@app/helpers'
6import { VideoService } from '@app/shared/shared-main'
7import { AbstractVideoList } from '@app/shared/shared-video-miniature'
8import { VideoSortField } from '@shared/models'
9import { VideoTrendingHeaderComponent } from './video-trending-header.component'
10
11@Component({
12 selector: 'my-videos-trending',
13 styleUrls: [ '../../../shared/shared-video-miniature/abstract-video-list.scss' ],
14 templateUrl: '../../../shared/shared-video-miniature/abstract-video-list.html'
15})
16export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
17 HeaderComponent = VideoTrendingHeaderComponent
18 titlePage: string
19 defaultSort: VideoSortField = '-trending'
20
21 useUserVideoPreferences = true
22
23 constructor (
24 protected router: Router,
25 protected serverService: ServerService,
26 protected route: ActivatedRoute,
27 protected notifier: Notifier,
28 protected authService: AuthService,
29 protected userService: UserService,
30 protected screenService: ScreenService,
31 protected storageService: LocalStorageService,
32 protected cfr: ComponentFactoryResolver,
33 private videoService: VideoService,
34 private hooks: HooksService
35 ) {
36 super()
37
38 this.headerComponentInjector = this.getInjector()
39 }
40
41 ngOnInit () {
42 super.ngOnInit()
43
44 this.generateSyndicationList()
45
46 this.serverService.getConfig().subscribe(
47 config => {
48 const trendingDays = config.trending.videos.intervalDays
49
50 if (trendingDays === 1) {
51 this.titleTooltip = $localize`Trending videos are those totalizing the greatest number of views during the last 24 hours`
52 } else {
53 this.titleTooltip = $localize`Trending videos are those totalizing the greatest number of views during the last ${trendingDays} days`
54 }
55
56 this.headerComponentInjector = this.getInjector()
57 this.setHeader()
58 })
59 }
60
61 ngOnDestroy () {
62 super.ngOnDestroy()
63 }
64
65 getVideosObservable (page: number) {
66 const newPagination = immutableAssign(this.pagination, { currentPage: page })
67 const params = {
68 videoPagination: newPagination,
69 sort: this.sort,
70 categoryOneOf: this.categoryOneOf,
71 languageOneOf: this.languageOneOf,
72 nsfwPolicy: this.nsfwPolicy,
73 skipCount: true
74 }
75
76 return this.hooks.wrapObsFun(
77 this.videoService.getVideos.bind(this.videoService),
78 params,
79 'common',
80 'filter:api.trending-videos.videos.list.params',
81 'filter:api.trending-videos.videos.list.result'
82 )
83 }
84
85 generateSyndicationList () {
86 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
87 }
88
89 getInjector () {
90 return Injector.create({
91 providers: [{
92 provide: 'data',
93 useValue: {
94 model: this.defaultSort
95 }
96 }]
97 })
98 }
99}