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'
11 selector: 'my-video-channel-videos',
12 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html',
14 '../../shared/shared-video-miniature/abstract-video-list.scss'
17 export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
21 private videoChannel: VideoChannel
22 private videoChannelSub: Subscription
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
39 this.titlePage = $localize`Published videos`
40 this.displayOptions = {
41 ...this.displayOptions,
49 // Parent get the video channel for us
50 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
52 .subscribe(videoChannel => {
53 this.videoChannel = videoChannel
56 this.generateSyndicationList()
61 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
66 getVideosObservable (page: number) {
67 const newPagination = immutableAssign(this.pagination, { currentPage: page })
69 return this.videoService
70 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort, this.nsfwPolicy)
73 this.titlePage = total === 1
74 ? $localize`Published 1 video`
75 : $localize`Published ${total} videos`
80 generateSyndicationList () {
81 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)