]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
Fix saved mute in embed
[github/Chocobozzz/PeerTube.git] / client / src / app / +video-channels / video-channel-videos / video-channel-videos.component.ts
CommitLineData
0626e7af
C
1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
0626e7af 3import { immutableAssign } from '@app/shared/misc/utils'
0626e7af
C
4import { AuthService } from '../../core/auth'
5import { ConfirmService } from '../../core/confirm'
6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7import { VideoService } from '../../shared/video/video.service'
170726f5
C
8import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
9import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
722bca90 10import { first, tap } from 'rxjs/operators'
b1d40cff 11import { I18n } from '@ngx-translate/i18n-polyfill'
734a5ceb 12import { Subscription } from 'rxjs'
bbe0f064 13import { ScreenService } from '@app/shared/misc/screen.service'
489290b8 14import { Notifier, ServerService } from '@app/core'
0626e7af
C
15
16@Component({
170726f5 17 selector: 'my-video-channel-videos',
0626e7af
C
18 templateUrl: '../../shared/video/abstract-video-list.html',
19 styleUrls: [
20 '../../shared/video/abstract-video-list.scss',
170726f5 21 './video-channel-videos.component.scss'
0626e7af
C
22 ]
23})
170726f5 24export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
b1d40cff 25 titlePage: string
0626e7af
C
26 loadOnInit = false
27
170726f5 28 private videoChannel: VideoChannel
734a5ceb 29 private videoChannelSub: Subscription
0626e7af
C
30
31 constructor (
34c7f429 32 protected i18n: I18n,
0626e7af 33 protected router: Router,
489290b8 34 protected serverService: ServerService,
0626e7af
C
35 protected route: ActivatedRoute,
36 protected authService: AuthService,
f8b2c1b4 37 protected notifier: Notifier,
0626e7af 38 protected confirmService: ConfirmService,
bbe0f064 39 protected screenService: ScreenService,
170726f5 40 private videoChannelService: VideoChannelService,
0626e7af
C
41 private videoService: VideoService
42 ) {
43 super()
b1d40cff
C
44
45 this.titlePage = this.i18n('Published videos')
0626e7af
C
46 }
47
48 ngOnInit () {
49 super.ngOnInit()
50
170726f5 51 // Parent get the video channel for us
734a5ceb 52 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
722bca90
C
53 .pipe(first())
54 .subscribe(videoChannel => {
55 this.videoChannel = videoChannel
0626e7af 56
722bca90
C
57 this.reloadVideos()
58 this.generateSyndicationList()
59 })
0626e7af
C
60 }
61
62 ngOnDestroy () {
734a5ceb
C
63 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
64
0626e7af
C
65 super.ngOnDestroy()
66 }
67
68 getVideosObservable (page: number) {
69 const newPagination = immutableAssign(this.pagination, { currentPage: page })
70
0bf1f265
C
71 return this.videoService
72 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort)
b1d40cff 73 .pipe(
93cae479 74 tap(({ total }) => {
0b1de586 75 this.titlePage = this.i18n(`{total, plural, =1 {Published 1 video} other {Published {{total}} videos}}`, { total })
b1d40cff
C
76 })
77 )
0626e7af
C
78 }
79
80 generateSyndicationList () {
170726f5 81 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
0626e7af
C
82 }
83}