1 import { Subscription } from 'rxjs'
2 import { first, tap } from 'rxjs/operators'
3 import { Component, ComponentFactoryResolver, 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 { VideoFilter } from '@shared/models'
12 selector: 'my-video-channel-videos',
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html',
15 '../../shared/shared-video-miniature/abstract-video-list.scss'
18 export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
22 filter: VideoFilter = null
24 private videoChannel: VideoChannel
25 private videoChannelSub: Subscription
28 protected router: Router,
29 protected serverService: ServerService,
30 protected route: ActivatedRoute,
31 protected authService: AuthService,
32 protected userService: UserService,
33 protected notifier: Notifier,
34 protected confirmService: ConfirmService,
35 protected screenService: ScreenService,
36 protected storageService: LocalStorageService,
37 protected cfr: ComponentFactoryResolver,
38 private videoChannelService: VideoChannelService,
39 private videoService: VideoService
43 this.titlePage = $localize`Published videos`
44 this.displayOptions = {
45 ...this.displayOptions,
53 this.enableAllFilterIfPossible()
55 // Parent get the video channel for us
56 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
58 .subscribe(videoChannel => {
59 this.videoChannel = videoChannel
62 this.generateSyndicationList()
67 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
72 getVideosObservable (page: number) {
73 const newPagination = immutableAssign(this.pagination, { currentPage: page })
75 videoChannel: this.videoChannel,
76 videoPagination: newPagination,
78 nsfwPolicy: this.nsfwPolicy,
79 videoFilter: this.filter
82 return this.videoService
83 .getVideoChannelVideos(options)
86 this.titlePage = total === 1
87 ? $localize`Published 1 video`
88 : $localize`Published ${total} videos`
93 generateSyndicationList () {
94 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
97 toggleModerationDisplay () {
98 this.filter = this.buildLocalFilter(this.filter, null)