]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
Reorganize client shared modules
[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'
b1d40cff 9import { I18n } from '@ngx-translate/i18n-polyfill'
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: [
67ed6552 15 '../../shared/shared-video-miniature/abstract-video-list.scss',
170726f5 16 './video-channel-videos.component.scss'
0626e7af
C
17 ]
18})
170726f5 19export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
b1d40cff 20 titlePage: string
0626e7af
C
21 loadOnInit = false
22
170726f5 23 private videoChannel: VideoChannel
734a5ceb 24 private videoChannelSub: Subscription
0626e7af
C
25
26 constructor (
34c7f429 27 protected i18n: I18n,
0626e7af 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
C
41
42 this.titlePage = this.i18n('Published videos')
e66883b3
RK
43 this.displayOptions = {
44 ...this.displayOptions,
45 avatar: false
46 }
0626e7af
C
47 }
48
49 ngOnInit () {
50 super.ngOnInit()
51
170726f5 52 // Parent get the video channel for us
734a5ceb 53 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
722bca90
C
54 .pipe(first())
55 .subscribe(videoChannel => {
56 this.videoChannel = videoChannel
0626e7af 57
722bca90
C
58 this.reloadVideos()
59 this.generateSyndicationList()
60 })
0626e7af
C
61 }
62
63 ngOnDestroy () {
734a5ceb
C
64 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
65
0626e7af
C
66 super.ngOnDestroy()
67 }
68
69 getVideosObservable (page: number) {
70 const newPagination = immutableAssign(this.pagination, { currentPage: page })
71
0bf1f265 72 return this.videoService
5c20a455 73 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort, this.nsfwPolicy)
b1d40cff 74 .pipe(
93cae479 75 tap(({ total }) => {
0b1de586 76 this.titlePage = this.i18n(`{total, plural, =1 {Published 1 video} other {Published {{total}} videos}}`, { total })
b1d40cff
C
77 })
78 )
0626e7af
C
79 }
80
81 generateSyndicationList () {
170726f5 82 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
0626e7af
C
83 }
84}