1 import { forkJoin, Subscription } from 'rxjs'
2 import { first } 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 {
19 // No value because we don't want a page title
22 loadUserVideoPreferences = true
24 filter: VideoFilter = null
26 displayOptions: MiniatureDisplayOptions = {
37 private videoChannel: VideoChannel
38 private videoChannelSub: Subscription
41 protected router: Router,
42 protected serverService: ServerService,
43 protected route: ActivatedRoute,
44 protected authService: AuthService,
45 protected userService: UserService,
46 protected notifier: Notifier,
47 protected confirmService: ConfirmService,
48 protected screenService: ScreenService,
49 protected storageService: LocalStorageService,
50 protected cfr: ComponentFactoryResolver,
51 private videoChannelService: VideoChannelService,
52 private videoService: VideoService
56 this.titlePage = $localize`Published videos`
57 this.displayOptions = {
58 ...this.displayOptions,
66 this.enableAllFilterIfPossible()
68 // Parent get the video channel for us
69 this.videoChannelSub = forkJoin([
70 this.videoChannelService.videoChannelLoaded.pipe(first()),
71 this.onUserLoadedSubject.pipe(first())
72 ]).subscribe(([ videoChannel ]) => {
73 this.videoChannel = videoChannel
76 this.generateSyndicationList()
81 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
86 getVideosObservable (page: number) {
87 const newPagination = immutableAssign(this.pagination, { currentPage: page })
89 videoChannel: this.videoChannel,
90 videoPagination: newPagination,
92 nsfwPolicy: this.nsfwPolicy,
93 videoFilter: this.filter
96 return this.videoService
97 .getVideoChannelVideos(options)
100 generateSyndicationList () {
101 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
104 toggleModerationDisplay () {
105 this.filter = this.buildLocalFilter(this.filter, null)
111 return this.screenService.isInMobileView()