]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
Fix rss feed with HLS videos
[github/Chocobozzz/PeerTube.git] / client / src / app / +video-channels / video-channel-videos / video-channel-videos.component.ts
CommitLineData
67ed6552
C
1import { Subscription } from 'rxjs'
2import { first, tap } from 'rxjs/operators'
0626e7af
C
3import { Component, OnDestroy, OnInit } from '@angular/core'
4import { ActivatedRoute, Router } from '@angular/router'
67ed6552
C
5import { AuthService, ConfirmService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
6import { immutableAssign } from '@app/helpers'
7import { VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
8import { AbstractVideoList } from '@app/shared/shared-video-miniature'
0aa52e17 9import { 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 18export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
b1d40cff 19 titlePage: string
0626e7af
C
20 loadOnInit = false
21
0aa52e17
C
22 filter: VideoFilter = null
23
170726f5 24 private videoChannel: VideoChannel
734a5ceb 25 private videoChannelSub: Subscription
0626e7af
C
26
27 constructor (
28 protected router: Router,
489290b8 29 protected serverService: ServerService,
0626e7af
C
30 protected route: ActivatedRoute,
31 protected authService: AuthService,
d3217560 32 protected userService: UserService,
f8b2c1b4 33 protected notifier: Notifier,
0626e7af 34 protected confirmService: ConfirmService,
bbe0f064 35 protected screenService: ScreenService,
d3217560 36 protected storageService: LocalStorageService,
170726f5 37 private videoChannelService: VideoChannelService,
0626e7af
C
38 private videoService: VideoService
39 ) {
40 super()
b1d40cff 41
66357162 42 this.titlePage = $localize`Published videos`
e66883b3
RK
43 this.displayOptions = {
44 ...this.displayOptions,
45 avatar: false
46 }
0626e7af
C
47 }
48
49 ngOnInit () {
50 super.ngOnInit()
51
0aa52e17
C
52 this.enableAllFilterIfPossible()
53
170726f5 54 // Parent get the video channel for us
734a5ceb 55 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
722bca90
C
56 .pipe(first())
57 .subscribe(videoChannel => {
58 this.videoChannel = videoChannel
0626e7af 59
722bca90
C
60 this.reloadVideos()
61 this.generateSyndicationList()
62 })
0626e7af
C
63 }
64
65 ngOnDestroy () {
734a5ceb
C
66 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
67
0626e7af
C
68 super.ngOnDestroy()
69 }
70
71 getVideosObservable (page: number) {
72 const newPagination = immutableAssign(this.pagination, { currentPage: page })
0aa52e17
C
73 const options = {
74 videoChannel: this.videoChannel,
75 videoPagination: newPagination,
76 sort: this.sort,
77 nsfwPolicy: this.nsfwPolicy,
78 videoFilter: this.filter
79 }
0626e7af 80
0bf1f265 81 return this.videoService
0aa52e17 82 .getVideoChannelVideos(options)
b1d40cff 83 .pipe(
93cae479 84 tap(({ total }) => {
66357162
C
85 this.titlePage = total === 1
86 ? $localize`Published 1 video`
87 : $localize`Published ${total} videos`
b1d40cff
C
88 })
89 )
0626e7af
C
90 }
91
92 generateSyndicationList () {
170726f5 93 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
0626e7af 94 }
0aa52e17
C
95
96 toggleModerationDisplay () {
97 this.filter = this.buildLocalFilter(this.filter, null)
98
99 this.reloadVideos()
100 }
0626e7af 101}