]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+videos/video-list/video-most-liked.component.ts
Migrate to $localize
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / video-list / video-most-liked.component.ts
CommitLineData
c07eb946
JM
1import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
67ed6552 3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
c07eb946 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'
c07eb946
JM
9
10@Component({
11 selector: 'my-videos-most-liked',
67ed6552
C
12 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
c07eb946
JM
14})
15export class VideoMostLikedComponent extends AbstractVideoList implements OnInit {
16 titlePage: string
17 defaultSort: VideoSortField = '-likes'
18
5c20a455 19 useUserVideoPreferences = true
c07eb946
JM
20
21 constructor (
c07eb946
JM
22 protected router: Router,
23 protected serverService: ServerService,
24 protected route: ActivatedRoute,
25 protected notifier: Notifier,
26 protected authService: AuthService,
d3217560 27 protected userService: UserService,
c07eb946 28 protected screenService: ScreenService,
d3217560 29 protected storageService: LocalStorageService,
c07eb946
JM
30 private videoService: VideoService,
31 private hooks: HooksService
32 ) {
33 super()
34 }
35
36 ngOnInit () {
37 super.ngOnInit()
38
39 this.generateSyndicationList()
40
66357162
C
41 this.titlePage = $localize`Most liked videos`
42 this.titleTooltip = $localize`Videos that have the higher number of likes.`
c07eb946
JM
43 }
44
45 getVideosObservable (page: number) {
46 const newPagination = immutableAssign(this.pagination, { currentPage: page })
47 const params = {
48 videoPagination: newPagination,
49 sort: this.sort,
50 categoryOneOf: this.categoryOneOf,
440d39c5 51 languageOneOf: this.languageOneOf,
5c20a455 52 nsfwPolicy: this.nsfwPolicy,
440d39c5 53 skipCount: true
c07eb946
JM
54 }
55
56 return this.hooks.wrapObsFun(
57 this.videoService.getVideos.bind(this.videoService),
58 params,
59 'common',
60 'filter:api.most-liked-videos.videos.list.params',
61 'filter:api.most-liked-videos.videos.list.result'
62 )
63 }
64
65 generateSyndicationList () {
66 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
67 }
68}