]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - 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
1 import { Subscription } from 'rxjs'
2 import { first, tap } from 'rxjs/operators'
3 import { Component, OnDestroy, OnInit } from '@angular/core'
4 import { ActivatedRoute, Router } from '@angular/router'
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'
8 import { AbstractVideoList } from '@app/shared/shared-video-miniature'
9 import { I18n } from '@ngx-translate/i18n-polyfill'
10
11 @Component({
12 selector: 'my-video-channel-videos',
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html',
14 styleUrls: [
15 '../../shared/shared-video-miniature/abstract-video-list.scss'
16 ]
17 })
18 export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
19 titlePage: string
20 loadOnInit = false
21
22 private videoChannel: VideoChannel
23 private videoChannelSub: Subscription
24
25 constructor (
26 protected i18n: I18n,
27 protected router: Router,
28 protected serverService: ServerService,
29 protected route: ActivatedRoute,
30 protected authService: AuthService,
31 protected userService: UserService,
32 protected notifier: Notifier,
33 protected confirmService: ConfirmService,
34 protected screenService: ScreenService,
35 protected storageService: LocalStorageService,
36 private videoChannelService: VideoChannelService,
37 private videoService: VideoService
38 ) {
39 super()
40
41 this.titlePage = this.i18n('Published videos')
42 this.displayOptions = {
43 ...this.displayOptions,
44 avatar: false
45 }
46 }
47
48 ngOnInit () {
49 super.ngOnInit()
50
51 // Parent get the video channel for us
52 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
53 .pipe(first())
54 .subscribe(videoChannel => {
55 this.videoChannel = videoChannel
56
57 this.reloadVideos()
58 this.generateSyndicationList()
59 })
60 }
61
62 ngOnDestroy () {
63 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
64
65 super.ngOnDestroy()
66 }
67
68 getVideosObservable (page: number) {
69 const newPagination = immutableAssign(this.pagination, { currentPage: page })
70
71 return this.videoService
72 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort, this.nsfwPolicy)
73 .pipe(
74 tap(({ total }) => {
75 this.titlePage = this.i18n(`{total, plural, =1 {Published 1 video} other {Published {{total}} videos}}`, { total })
76 })
77 )
78 }
79
80 generateSyndicationList () {
81 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
82 }
83 }