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