1 import { Subscription } from 'rxjs'
2 import { first } from 'rxjs/operators'
3 import { Component, OnDestroy, OnInit } from '@angular/core'
4 import { ComponentPaginationLight, DisableForReuseHook, ScreenService } from '@app/core'
5 import { VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
6 import { MiniatureDisplayOptions, VideoFilters } from '@app/shared/shared-video-miniature'
7 import { VideoSortField } from '@shared/models/videos'
10 selector: 'my-video-channel-videos',
11 templateUrl: './video-channel-videos.component.html'
13 export class VideoChannelVideosComponent implements OnInit, OnDestroy, DisableForReuseHook {
14 getVideosObservableFunction = this.getVideosObservable.bind(this)
15 getSyndicationItemsFunction = this.getSyndicationItems.bind(this)
17 title = $localize`Videos`
18 defaultSort = '-publishedAt' as VideoSortField
20 displayOptions: MiniatureDisplayOptions = {
31 videoChannel: VideoChannel
34 private videoChannelSub: Subscription
37 private screenService: ScreenService,
38 private videoChannelService: VideoChannelService,
39 private videoService: VideoService
44 // Parent get the video channel for us
45 this.videoChannelService.videoChannelLoaded.pipe(first())
46 .subscribe(videoChannel => {
47 this.videoChannel = videoChannel
52 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
55 getVideosObservable (pagination: ComponentPaginationLight, filters: VideoFilters) {
57 ...filters.toVideosAPIObject(),
59 videoPagination: pagination,
60 videoChannel: this.videoChannel,
64 return this.videoService.getVideoChannelVideos(params)
67 getSyndicationItems () {
68 return this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
72 return this.screenService.isInMobileView()