X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bvideo-channels%2Fvideo-channel-playlists%2Fvideo-channel-playlists.component.ts;h=82af650265be57d0ed98fe752f9e3998981f0a4d;hb=9ca0f688e9e8558233f1a538b96a43da44e35353;hp=7990044a2baababf4c830c895eeb2552c05e9b12;hpb=c8487f3f63c90fbfddaa906b3cbd90fb209ab1bb;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts index 7990044a2..82af65026 100644 --- a/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts +++ b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts @@ -1,19 +1,15 @@ -import { Component, OnDestroy, OnInit } from '@angular/core' -import { ConfirmService } from '../../core/confirm' -import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' -import { VideoChannel } from '@app/shared/video-channel/video-channel.model' -import { Subscription } from 'rxjs' -import { Notifier } from '@app/core' -import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model' -import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model' -import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' +import { Subject, Subscription } from 'rxjs' +import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core' +import { ComponentPagination, hasMoreItems, HooksService, ScreenService } from '@app/core' +import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' +import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' @Component({ selector: 'my-video-channel-playlists', templateUrl: './video-channel-playlists.component.html', styleUrls: [ './video-channel-playlists.component.scss' ] }) -export class VideoChannelPlaylistsComponent implements OnInit, OnDestroy { +export class VideoChannelPlaylistsComponent implements OnInit, AfterViewInit, OnDestroy { videoPlaylists: VideoPlaylist[] = [] pagination: ComponentPagination = { @@ -22,23 +18,32 @@ export class VideoChannelPlaylistsComponent implements OnInit, OnDestroy { totalItems: null } + onDataSubject = new Subject() + private videoChannelSub: Subscription private videoChannel: VideoChannel constructor ( - private notifier: Notifier, - private confirmService: ConfirmService, private videoPlaylistService: VideoPlaylistService, - private videoChannelService: VideoChannelService + private videoChannelService: VideoChannelService, + private screenService: ScreenService, + private hooks: HooksService ) {} ngOnInit () { // Parent get the video channel for us this.videoChannelSub = this.videoChannelService.videoChannelLoaded - .subscribe(videoChannel => { - this.videoChannel = videoChannel - this.loadVideoPlaylists() - }) + .subscribe(videoChannel => { + this.videoChannel = videoChannel + + this.hooks.runAction('action:video-channel-playlists.video-channel.loaded', 'video-channel', { videoChannel }) + + this.loadVideoPlaylists() + }) + } + + ngAfterViewInit () { + this.hooks.runAction('action:video-channel-playlists.init', 'video-channel') } ngOnDestroy () { @@ -52,11 +57,19 @@ export class VideoChannelPlaylistsComponent implements OnInit, OnDestroy { this.loadVideoPlaylists() } + displayAsRow () { + return this.screenService.isInMobileView() + } + private loadVideoPlaylists () { - this.videoPlaylistService.listChannelPlaylists(this.videoChannel) - .subscribe(res => { - this.videoPlaylists = this.videoPlaylists.concat(res.data) - this.pagination.totalItems = res.total - }) + this.videoPlaylistService.listChannelPlaylists(this.videoChannel, this.pagination) + .subscribe(res => { + this.videoPlaylists = this.videoPlaylists.concat(res.data) + this.pagination.totalItems = res.total + + this.hooks.runAction('action:video-channel-playlists.playlists.loaded', 'video-channel', { playlists: this.videoPlaylists }) + + this.onDataSubject.next(res.data) + }) } }