]>
Commit | Line | Data |
---|---|---|
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 { UserRight, VideoFilter, VideoSortField } from '@shared/models' | |
9 | ||
10 | @Component({ | |
11 | selector: 'my-videos-local', | |
12 | styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ], | |
13 | templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html' | |
14 | }) | |
15 | export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy { | |
16 | titlePage: string | |
17 | sort = '-publishedAt' as VideoSortField | |
18 | filter: VideoFilter = 'local' | |
19 | ||
20 | useUserVideoPreferences = true | |
21 | ||
22 | constructor ( | |
23 | protected router: Router, | |
24 | protected serverService: ServerService, | |
25 | protected route: ActivatedRoute, | |
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`Local videos` | |
37 | } | |
38 | ||
39 | ngOnInit () { | |
40 | super.ngOnInit() | |
41 | ||
42 | this.enableAllFilterIfPossible() | |
43 | this.generateSyndicationList() | |
44 | } | |
45 | ||
46 | ngOnDestroy () { | |
47 | super.ngOnDestroy() | |
48 | } | |
49 | ||
50 | getVideosObservable (page: number) { | |
51 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
52 | const params = { | |
53 | videoPagination: newPagination, | |
54 | sort: this.sort, | |
55 | filter: this.filter, | |
56 | categoryOneOf: this.categoryOneOf, | |
57 | languageOneOf: this.languageOneOf, | |
58 | nsfwPolicy: this.nsfwPolicy, | |
59 | skipCount: true | |
60 | } | |
61 | ||
62 | return this.hooks.wrapObsFun( | |
63 | this.videoService.getVideos.bind(this.videoService), | |
64 | params, | |
65 | 'common', | |
66 | 'filter:api.local-videos.videos.list.params', | |
67 | 'filter:api.local-videos.videos.list.result' | |
68 | ) | |
69 | } | |
70 | ||
71 | generateSyndicationList () { | |
72 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf) | |
73 | } | |
74 | ||
75 | toggleModerationDisplay () { | |
76 | this.filter = this.buildLocalFilter(this.filter, 'local') | |
77 | ||
78 | this.reloadVideos() | |
79 | } | |
80 | } |