1 import { forkJoin, 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 {
21 loadUserVideoPreferences = true
23 filter: VideoFilter = null
25 private videoChannel: VideoChannel
26 private videoChannelSub: Subscription
29 protected router: Router,
30 protected serverService: ServerService,
31 protected route: ActivatedRoute,
32 protected authService: AuthService,
33 protected userService: UserService,
34 protected notifier: Notifier,
35 protected confirmService: ConfirmService,
36 protected screenService: ScreenService,
37 protected storageService: LocalStorageService,
38 protected cfr: ComponentFactoryResolver,
39 private videoChannelService: VideoChannelService,
40 private videoService: VideoService
44 this.titlePage = $localize`Published videos`
45 this.displayOptions = {
46 ...this.displayOptions,
54 this.enableAllFilterIfPossible()
56 // Parent get the video channel for us
57 this.videoChannelSub = forkJoin([
58 this.videoChannelService.videoChannelLoaded.pipe(first()),
59 this.onUserLoadedSubject.pipe(first())
60 ]).subscribe(([ videoChannel ]) => {
61 this.videoChannel = videoChannel
64 this.generateSyndicationList()
69 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
74 getVideosObservable (page: number) {
75 const newPagination = immutableAssign(this.pagination, { currentPage: page })
77 videoChannel: this.videoChannel,
78 videoPagination: newPagination,
80 nsfwPolicy: this.nsfwPolicy,
81 videoFilter: this.filter
84 return this.videoService
85 .getVideoChannelVideos(options)
88 this.titlePage = total === 1
89 ? $localize`Published 1 video`
90 : $localize`Published ${total} videos`
95 generateSyndicationList () {
96 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
99 toggleModerationDisplay () {
100 this.filter = this.buildLocalFilter(this.filter, null)