]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-most-liked.component.ts
Fix scrolling with hash in url
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-most-liked.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { immutableAssign } from '@app/shared/misc/utils'
4 import { AuthService } from '../../core/auth'
5 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
6 import { VideoSortField } from '../../shared/video/sort-field.type'
7 import { VideoService } from '../../shared/video/video.service'
8 import { I18n } from '@ngx-translate/i18n-polyfill'
9 import { ScreenService } from '@app/shared/misc/screen.service'
10 import { Notifier, ServerService } from '@app/core'
11 import { HooksService } from '@app/core/plugins/hooks.service'
12 import { UserService } from '@app/shared'
13 import { LocalStorageService } from '@app/shared/misc/storage.service'
14
15 @Component({
16 selector: 'my-videos-most-liked',
17 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
18 templateUrl: '../../shared/video/abstract-video-list.html'
19 })
20 export class VideoMostLikedComponent extends AbstractVideoList implements OnInit {
21 titlePage: string
22 defaultSort: VideoSortField = '-likes'
23
24 useUserVideoLanguagePreferences = true
25
26 constructor (
27 protected i18n: I18n,
28 protected router: Router,
29 protected serverService: ServerService,
30 protected route: ActivatedRoute,
31 protected notifier: Notifier,
32 protected authService: AuthService,
33 protected userService: UserService,
34 protected screenService: ScreenService,
35 protected storageService: LocalStorageService,
36 private videoService: VideoService,
37 private hooks: HooksService
38 ) {
39 super()
40 }
41
42 ngOnInit () {
43 super.ngOnInit()
44
45 this.generateSyndicationList()
46
47 this.titlePage = this.i18n('Most liked videos')
48 this.titleTooltip = this.i18n('Videos that have the higher number of likes.')
49 }
50
51 getVideosObservable (page: number) {
52 const newPagination = immutableAssign(this.pagination, { currentPage: page })
53 const params = {
54 videoPagination: newPagination,
55 sort: this.sort,
56 categoryOneOf: this.categoryOneOf,
57 languageOneOf: this.languageOneOf,
58 skipCount: true
59 }
60
61 return this.hooks.wrapObsFun(
62 this.videoService.getVideos.bind(this.videoService),
63 params,
64 'common',
65 'filter:api.most-liked-videos.videos.list.params',
66 'filter:api.most-liked-videos.videos.list.result'
67 )
68 }
69
70 generateSyndicationList () {
71 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
72 }
73 }