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