]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-recently-added.component.ts
5c50fd396eee4b867ff616b3071788aa2bbc5d5a
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-recently-added.component.ts
1 import { Component, OnDestroy, 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
13 @Component({
14 selector: 'my-videos-recently-added',
15 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
16 templateUrl: '../../shared/video/abstract-video-list.html'
17 })
18 export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit, OnDestroy {
19 titlePage: string
20 sort: VideoSortField = '-publishedAt'
21 groupByDate = true
22
23 useUserVideoLanguagePreferences = true
24
25 constructor (
26 protected i18n: I18n,
27 protected route: ActivatedRoute,
28 protected serverService: ServerService,
29 protected router: Router,
30 protected notifier: Notifier,
31 protected authService: AuthService,
32 protected screenService: ScreenService,
33 private videoService: VideoService,
34 private hooks: HooksService
35 ) {
36 super()
37
38 this.titlePage = i18n('Recently added')
39 }
40
41 ngOnInit () {
42 super.ngOnInit()
43
44 this.generateSyndicationList()
45 }
46
47 ngOnDestroy () {
48 super.ngOnDestroy()
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 }
59
60 return this.hooks.wrapObsFun(
61 this.videoService.getVideos.bind(this.videoService),
62 params,
63 'common',
64 'filter:api.recently-added-videos.videos.list.params',
65 'filter:api.recently-added-videos.videos.list.result'
66 )
67 }
68
69 generateSyndicationList () {
70 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
71 }
72 }