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, MiniatureDisplayOptions } 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 displayOptions: MiniatureDisplayOptions = {
36 private videoChannel: VideoChannel
37 private videoChannelSub: Subscription
40 protected router: Router,
41 protected serverService: ServerService,
42 protected route: ActivatedRoute,
43 protected authService: AuthService,
44 protected userService: UserService,
45 protected notifier: Notifier,
46 protected confirmService: ConfirmService,
47 protected screenService: ScreenService,
48 protected storageService: LocalStorageService,
49 protected cfr: ComponentFactoryResolver,
50 private videoChannelService: VideoChannelService,
51 private videoService: VideoService
55 this.titlePage = $localize`Published videos`
56 this.displayOptions = {
57 ...this.displayOptions,
65 this.enableAllFilterIfPossible()
67 // Parent get the video channel for us
68 this.videoChannelSub = forkJoin([
69 this.videoChannelService.videoChannelLoaded.pipe(first()),
70 this.onUserLoadedSubject.pipe(first())
71 ]).subscribe(([ videoChannel ]) => {
72 this.videoChannel = videoChannel
75 this.generateSyndicationList()
80 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
85 getVideosObservable (page: number) {
86 const newPagination = immutableAssign(this.pagination, { currentPage: page })
88 videoChannel: this.videoChannel,
89 videoPagination: newPagination,
91 nsfwPolicy: this.nsfwPolicy,
92 videoFilter: this.filter
95 return this.videoService
96 .getVideoChannelVideos(options)
99 this.titlePage = total === 1
100 ? $localize`Published 1 video`
101 : $localize`Published ${total} videos`
106 generateSyndicationList () {
107 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
110 toggleModerationDisplay () {
111 this.filter = this.buildLocalFilter(this.filter, null)
117 return this.screenService.isInMobileView()