]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+accounts/account-video-channels/account-video-channels.component.ts
Fix anonymous nsfw policy
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-video-channels / account-video-channels.component.ts
index 4d07d653f9adeafdf5e55c9fa8f32d08270bccc3..2e5c5aae216f33f3a8adfd1368607f0c028dd6a4 100644 (file)
@@ -1,16 +1,17 @@
+import { from, Subject, Subscription } from 'rxjs'
+import { concatMap, map, switchMap, tap } from 'rxjs/operators'
 import { Component, OnDestroy, OnInit } from '@angular/core'
-import { ActivatedRoute } from '@angular/router'
+import { UserService } from '@app/shared'
 import { Account } from '@app/shared/account/account.model'
 import { AccountService } from '@app/shared/account/account.service'
-import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
-import { concatMap, map, switchMap, tap } from 'rxjs/operators'
-import { from, Subscription } from 'rxjs'
+import { ScreenService } from '@app/shared/misc/screen.service'
+import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model'
 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
+import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
+import { VideoSortField } from '@app/shared/video/sort-field.type'
 import { Video } from '@app/shared/video/video.model'
-import { AuthService } from '@app/core'
 import { VideoService } from '@app/shared/video/video.service'
-import { VideoSortField } from '@app/shared/video/sort-field.type'
-import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model'
+import { User } from '@shared/models'
 
 @Component({
   selector: 'my-account-video-channels',
@@ -24,29 +25,31 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
 
   channelPagination: ComponentPagination = {
     currentPage: 1,
-    itemsPerPage: 2
+    itemsPerPage: 2,
+    totalItems: null
   }
 
   videosPagination: ComponentPagination = {
     currentPage: 1,
-    itemsPerPage: 12
+    itemsPerPage: 12,
+    totalItems: null
   }
   videosSort: VideoSortField = '-publishedAt'
 
+  onChannelDataSubject = new Subject<any>()
+
+  userMiniature: User
+
   private accountSub: Subscription
 
   constructor (
-    private route: ActivatedRoute,
-    private authService: AuthService,
     private accountService: AccountService,
     private videoChannelService: VideoChannelService,
-    private videoService: VideoService
+    private videoService: VideoService,
+    private screenService: ScreenService,
+    private userService: UserService
   ) { }
 
-  get user () {
-    return this.authService.getUser()
-  }
-
   ngOnInit () {
     // Parent get the account for us
     this.accountSub = this.accountService.accountLoaded
@@ -55,6 +58,9 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
 
           this.loadMoreChannels()
         })
+
+    this.userService.getAnonymousOrLoggedUser()
+      .subscribe(user => this.userMiniature = user)
   }
 
   ngOnDestroy () {
@@ -75,11 +81,16 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
         this.videoChannels.push(videoChannel)
 
         this.videos[videoChannel.id] = videos
+
+        this.onChannelDataSubject.next([ videoChannel ])
       })
   }
 
   getVideosOf (videoChannel: VideoChannel) {
-    return this.videos[ videoChannel.id ]
+    const numberOfVideos = this.screenService.getNumberOfAvailableMiniatures()
+
+    // 2 rows
+    return this.videos[ videoChannel.id ].slice(0, numberOfVideos * 2)
   }
 
   onNearOfBottom () {
@@ -89,4 +100,8 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
 
     this.loadMoreChannels()
   }
+
+  getVideoChannelLink (videoChannel: VideoChannel) {
+    return [ '/video-channels', videoChannel.nameWithHost ]
+  }
 }