]>
Commit | Line | Data |
---|---|---|
9af61e84 | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
9bf9d2a5 | 2 | import { ActivatedRoute, Router } from '@angular/router' |
67ed6552 | 3 | import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core' |
93cae479 | 4 | import { HooksService } from '@app/core/plugins/hooks.service' |
67ed6552 C |
5 | import { immutableAssign } from '@app/helpers' |
6 | import { VideoService } from '@app/shared/shared-main' | |
7 | import { AbstractVideoList } from '@app/shared/shared-video-miniature' | |
67ed6552 | 8 | import { VideoSortField } from '@shared/models' |
9bf9d2a5 C |
9 | |
10 | @Component({ | |
11 | selector: 'my-videos-recently-added', | |
67ed6552 C |
12 | styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ], |
13 | templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html' | |
9bf9d2a5 | 14 | }) |
9af61e84 | 15 | export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit, OnDestroy { |
989e526a | 16 | titlePage: string |
136cce4d | 17 | sort: VideoSortField = '-publishedAt' |
34c7f429 | 18 | groupByDate = true |
9bf9d2a5 | 19 | |
5c20a455 | 20 | useUserVideoPreferences = true |
3caf77d3 | 21 | |
989e526a | 22 | constructor ( |
989e526a | 23 | protected route: ActivatedRoute, |
489290b8 C |
24 | protected serverService: ServerService, |
25 | protected router: Router, | |
f8b2c1b4 | 26 | protected notifier: Notifier, |
989e526a | 27 | protected authService: AuthService, |
d3217560 | 28 | protected userService: UserService, |
bbe0f064 | 29 | protected screenService: ScreenService, |
d3217560 | 30 | protected storageService: LocalStorageService, |
93cae479 C |
31 | private videoService: VideoService, |
32 | private hooks: HooksService | |
989e526a | 33 | ) { |
9bf9d2a5 | 34 | super() |
989e526a | 35 | |
66357162 | 36 | this.titlePage = $localize`Recently added` |
9bf9d2a5 C |
37 | } |
38 | ||
39 | ngOnInit () { | |
40 | super.ngOnInit() | |
cc1561f9 | 41 | |
244e76a5 | 42 | this.generateSyndicationList() |
9bf9d2a5 C |
43 | } |
44 | ||
9af61e84 C |
45 | ngOnDestroy () { |
46 | super.ngOnDestroy() | |
47 | } | |
48 | ||
0cd4344f C |
49 | getVideosObservable (page: number) { |
50 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
93cae479 | 51 | const params = { |
3caf77d3 C |
52 | videoPagination: newPagination, |
53 | sort: this.sort, | |
3caf77d3 | 54 | categoryOneOf: this.categoryOneOf, |
440d39c5 | 55 | languageOneOf: this.languageOneOf, |
5c20a455 | 56 | nsfwPolicy: this.nsfwPolicy, |
440d39c5 | 57 | skipCount: true |
93cae479 C |
58 | } |
59 | ||
60 | return this.hooks.wrapObsFun( | |
61 | this.videoService.getVideos.bind(this.videoService), | |
62 | params, | |
63 | 'common', | |
7663e55a C |
64 | 'filter:api.recently-added-videos.videos.list.params', |
65 | 'filter:api.recently-added-videos.videos.list.result' | |
93cae479 | 66 | ) |
9bf9d2a5 | 67 | } |
244e76a5 RK |
68 | |
69 | generateSyndicationList () { | |
d59cba29 | 70 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf) |
244e76a5 | 71 | } |
9bf9d2a5 | 72 | } |