]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-recently-added.component.ts
provide specific engine boundaries for nodejs and yarn
[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 import { UserService } from '@app/shared'
13 import { 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 })
20 export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit, OnDestroy {
21 titlePage: string
22 sort: VideoSortField = '-publishedAt'
23 groupByDate = true
24
25 useUserVideoPreferences = 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 nsfwPolicy: this.nsfwPolicy,
63 skipCount: true
64 }
65
66 return this.hooks.wrapObsFun(
67 this.videoService.getVideos.bind(this.videoService),
68 params,
69 'common',
70 'filter:api.recently-added-videos.videos.list.params',
71 'filter:api.recently-added-videos.videos.list.result'
72 )
73 }
74
75 generateSyndicationList () {
76 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
77 }
78 }