]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
Correctly fix sub menu
[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: [
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
170726f5 22 private videoChannel: VideoChannel
734a5ceb 23 private videoChannelSub: Subscription
0626e7af
C
24
25 constructor (
34c7f429 26 protected i18n: I18n,
0626e7af 27 protected router: Router,
489290b8 28 protected serverService: ServerService,
0626e7af
C
29 protected route: ActivatedRoute,
30 protected authService: AuthService,
d3217560 31 protected userService: UserService,
f8b2c1b4 32 protected notifier: Notifier,
0626e7af 33 protected confirmService: ConfirmService,
bbe0f064 34 protected screenService: ScreenService,
d3217560 35 protected storageService: LocalStorageService,
170726f5 36 private videoChannelService: VideoChannelService,
0626e7af
C
37 private videoService: VideoService
38 ) {
39 super()
b1d40cff
C
40
41 this.titlePage = this.i18n('Published videos')
e66883b3
RK
42 this.displayOptions = {
43 ...this.displayOptions,
44 avatar: false
45 }
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 71 return this.videoService
5c20a455 72 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort, this.nsfwPolicy)
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}