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