]>
Commit | Line | Data |
---|---|---|
07f81d9d | 1 | import { forkJoin, Subscription } from 'rxjs' |
9df52d66 | 2 | import { first } from 'rxjs/operators' |
5bcbcbe3 | 3 | import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' |
0626e7af | 4 | import { ActivatedRoute, Router } from '@angular/router' |
67ed6552 C |
5 | import { AuthService, ConfirmService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core' |
6 | import { immutableAssign } from '@app/helpers' | |
7 | import { VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' | |
900f7820 | 8 | import { AbstractVideoList, MiniatureDisplayOptions } from '@app/shared/shared-video-miniature' |
0aa52e17 | 9 | import { VideoFilter } from '@shared/models' |
0626e7af C |
10 | |
11 | @Component({ | |
170726f5 | 12 | selector: 'my-video-channel-videos', |
67ed6552 | 13 | templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html', |
0626e7af | 14 | styleUrls: [ |
ae2dd046 | 15 | '../../shared/shared-video-miniature/abstract-video-list.scss' |
0626e7af C |
16 | ] |
17 | }) | |
170726f5 | 18 | export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { |
4363ce0e | 19 | // No value because we don't want a page title |
b1d40cff | 20 | titlePage: string |
0626e7af | 21 | loadOnInit = false |
07f81d9d | 22 | loadUserVideoPreferences = true |
0626e7af | 23 | |
0aa52e17 C |
24 | filter: VideoFilter = null |
25 | ||
900f7820 C |
26 | displayOptions: MiniatureDisplayOptions = { |
27 | date: true, | |
28 | views: true, | |
29 | by: false, | |
30 | avatar: false, | |
31 | privacyLabel: true, | |
32 | privacyText: false, | |
33 | state: false, | |
34 | blacklistInfo: false | |
35 | } | |
36 | ||
170726f5 | 37 | private videoChannel: VideoChannel |
734a5ceb | 38 | private videoChannelSub: Subscription |
0626e7af C |
39 | |
40 | constructor ( | |
41 | protected router: Router, | |
489290b8 | 42 | protected serverService: ServerService, |
0626e7af C |
43 | protected route: ActivatedRoute, |
44 | protected authService: AuthService, | |
d3217560 | 45 | protected userService: UserService, |
f8b2c1b4 | 46 | protected notifier: Notifier, |
0626e7af | 47 | protected confirmService: ConfirmService, |
bbe0f064 | 48 | protected screenService: ScreenService, |
d3217560 | 49 | protected storageService: LocalStorageService, |
5bcbcbe3 | 50 | protected cfr: ComponentFactoryResolver, |
170726f5 | 51 | private videoChannelService: VideoChannelService, |
0626e7af C |
52 | private videoService: VideoService |
53 | ) { | |
54 | super() | |
b1d40cff | 55 | |
66357162 | 56 | this.titlePage = $localize`Published videos` |
e66883b3 RK |
57 | this.displayOptions = { |
58 | ...this.displayOptions, | |
59 | avatar: false | |
60 | } | |
0626e7af C |
61 | } |
62 | ||
63 | ngOnInit () { | |
64 | super.ngOnInit() | |
65 | ||
0aa52e17 C |
66 | this.enableAllFilterIfPossible() |
67 | ||
170726f5 | 68 | // Parent get the video channel for us |
07f81d9d C |
69 | this.videoChannelSub = forkJoin([ |
70 | this.videoChannelService.videoChannelLoaded.pipe(first()), | |
71 | this.onUserLoadedSubject.pipe(first()) | |
72 | ]).subscribe(([ videoChannel ]) => { | |
73 | this.videoChannel = videoChannel | |
74 | ||
75 | this.reloadVideos() | |
76 | this.generateSyndicationList() | |
77 | }) | |
0626e7af C |
78 | } |
79 | ||
80 | ngOnDestroy () { | |
734a5ceb C |
81 | if (this.videoChannelSub) this.videoChannelSub.unsubscribe() |
82 | ||
0626e7af C |
83 | super.ngOnDestroy() |
84 | } | |
85 | ||
86 | getVideosObservable (page: number) { | |
87 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
0aa52e17 C |
88 | const options = { |
89 | videoChannel: this.videoChannel, | |
90 | videoPagination: newPagination, | |
91 | sort: this.sort, | |
92 | nsfwPolicy: this.nsfwPolicy, | |
93 | videoFilter: this.filter | |
94 | } | |
0626e7af | 95 | |
0bf1f265 | 96 | return this.videoService |
0aa52e17 | 97 | .getVideoChannelVideos(options) |
0626e7af C |
98 | } |
99 | ||
100 | generateSyndicationList () { | |
170726f5 | 101 | this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id) |
0626e7af | 102 | } |
0aa52e17 C |
103 | |
104 | toggleModerationDisplay () { | |
105 | this.filter = this.buildLocalFilter(this.filter, null) | |
106 | ||
107 | this.reloadVideos() | |
108 | } | |
4d5e572f C |
109 | |
110 | displayAsRow () { | |
111 | return this.screenService.isInMobileView() | |
112 | } | |
0626e7af | 113 | } |