]>
Commit | Line | Data |
---|---|---|
5bcbcbe3 | 1 | import { Component, ComponentFactoryResolver, 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 | |
07f81d9d | 20 | loadUserVideoPreferences = 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, |
5bcbcbe3 | 31 | protected cfr: ComponentFactoryResolver, |
93cae479 C |
32 | private videoService: VideoService, |
33 | private hooks: HooksService | |
989e526a | 34 | ) { |
9bf9d2a5 | 35 | super() |
989e526a | 36 | |
66357162 | 37 | this.titlePage = $localize`Recently added` |
9bf9d2a5 C |
38 | } |
39 | ||
40 | ngOnInit () { | |
41 | super.ngOnInit() | |
cc1561f9 | 42 | |
244e76a5 | 43 | this.generateSyndicationList() |
9bf9d2a5 C |
44 | } |
45 | ||
9af61e84 C |
46 | ngOnDestroy () { |
47 | super.ngOnDestroy() | |
48 | } | |
49 | ||
0cd4344f C |
50 | getVideosObservable (page: number) { |
51 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
93cae479 | 52 | const params = { |
3caf77d3 C |
53 | videoPagination: newPagination, |
54 | sort: this.sort, | |
3caf77d3 | 55 | categoryOneOf: this.categoryOneOf, |
440d39c5 | 56 | languageOneOf: this.languageOneOf, |
5c20a455 | 57 | nsfwPolicy: this.nsfwPolicy, |
440d39c5 | 58 | skipCount: true |
93cae479 C |
59 | } |
60 | ||
61 | return this.hooks.wrapObsFun( | |
62 | this.videoService.getVideos.bind(this.videoService), | |
63 | params, | |
64 | 'common', | |
7663e55a C |
65 | 'filter:api.recently-added-videos.videos.list.params', |
66 | 'filter:api.recently-added-videos.videos.list.result' | |
93cae479 | 67 | ) |
9bf9d2a5 | 68 | } |
244e76a5 RK |
69 | |
70 | generateSyndicationList () { | |
d59cba29 | 71 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf) |
244e76a5 | 72 | } |
9bf9d2a5 | 73 | } |