]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+videos/video-list/video-recently-added.component.ts
Migrate to $localize
[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 { 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 { VideoSortField } from '@shared/models'
9
10 @Component({
11 selector: 'my-videos-recently-added',
12 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
14 })
15 export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit, OnDestroy {
16 titlePage: string
17 sort: VideoSortField = '-publishedAt'
18 groupByDate = true
19
20 useUserVideoPreferences = true
21
22 constructor (
23 protected route: ActivatedRoute,
24 protected serverService: ServerService,
25 protected router: Router,
26 protected notifier: Notifier,
27 protected authService: AuthService,
28 protected userService: UserService,
29 protected screenService: ScreenService,
30 protected storageService: LocalStorageService,
31 private videoService: VideoService,
32 private hooks: HooksService
33 ) {
34 super()
35
36 this.titlePage = $localize`Recently added`
37 }
38
39 ngOnInit () {
40 super.ngOnInit()
41
42 this.generateSyndicationList()
43 }
44
45 ngOnDestroy () {
46 super.ngOnDestroy()
47 }
48
49 getVideosObservable (page: number) {
50 const newPagination = immutableAssign(this.pagination, { currentPage: page })
51 const params = {
52 videoPagination: newPagination,
53 sort: this.sort,
54 categoryOneOf: this.categoryOneOf,
55 languageOneOf: this.languageOneOf,
56 nsfwPolicy: this.nsfwPolicy,
57 skipCount: true
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 }