1 import { Component, 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 { I18n } from '@ngx-translate/i18n-polyfill'
9 import { VideoSortField } from '@shared/models'
12 selector: 'my-videos-most-liked',
13 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
14 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
16 export class VideoMostLikedComponent extends AbstractVideoList implements OnInit {
18 defaultSort: VideoSortField = '-likes'
20 useUserVideoPreferences = true
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 private videoService: VideoService,
33 private hooks: HooksService
41 this.generateSyndicationList()
43 this.titlePage = this.i18n('Most liked videos')
44 this.titleTooltip = this.i18n('Videos that have the higher number of likes.')
47 getVideosObservable (page: number) {
48 const newPagination = immutableAssign(this.pagination, { currentPage: page })
50 videoPagination: newPagination,
52 categoryOneOf: this.categoryOneOf,
53 languageOneOf: this.languageOneOf,
54 nsfwPolicy: this.nsfwPolicy,
58 return this.hooks.wrapObsFun(
59 this.videoService.getVideos.bind(this.videoService),
62 'filter:api.most-liked-videos.videos.list.params',
63 'filter:api.most-liked-videos.videos.list.result'
67 generateSyndicationList () {
68 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)