]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.ts
Move admin stuff in +admin
[github/Chocobozzz/PeerTube.git] / client / src / app / +video-channels / video-channel-playlists / video-channel-playlists.component.ts
index 907aefae13136256ed6d55eb9761e27034627b18..14465bb8dd6947b52816a560b54c3eacfd0b402b 100644 (file)
@@ -1,12 +1,8 @@
+import { Subject, Subscription } from 'rxjs'
 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 } from '@app/shared/rest/component-pagination.model'
-import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service'
+import { ComponentPagination, hasMoreItems, 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',
@@ -22,14 +18,15 @@ export class VideoChannelPlaylistsComponent implements OnInit, OnDestroy {
     totalItems: null
   }
 
+  onDataSubject = new Subject<any[]>()
+
   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
   ) {}
 
   ngOnInit () {
@@ -46,18 +43,23 @@ export class VideoChannelPlaylistsComponent implements OnInit, OnDestroy {
   }
 
   onNearOfBottom () {
-    // Last page
-    if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return
+    if (!hasMoreItems(this.pagination)) return
 
     this.pagination.currentPage += 1
     this.loadVideoPlaylists()
   }
 
+  displayAsRow () {
+    return this.screenService.isInMobileView()
+  }
+
   private loadVideoPlaylists () {
-    this.videoPlaylistService.listChannelPlaylists(this.videoChannel)
+    this.videoPlaylistService.listChannelPlaylists(this.videoChannel, this.pagination)
         .subscribe(res => {
           this.videoPlaylists = this.videoPlaylists.concat(res.data)
           this.pagination.totalItems = res.total
+
+          this.onDataSubject.next(res.data)
         })
   }
 }