X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Baccounts%2Faccount-video-channels%2Faccount-video-channels.component.ts;h=205245675af0d19b483b809df2969f93fa4a23e9;hb=67ed6552b831df66713bac9e672738796128d33f;hp=a8d4237e81242c5cabf834e0d5794cfd1913881e;hpb=b6a1dd4d1b3b0032f8b968e72cbd074f646e8827;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts index a8d4237e8..205245675 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts @@ -1,16 +1,9 @@ -import { Component, OnDestroy, OnInit } from '@angular/core' -import { ActivatedRoute } from '@angular/router' -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 { from, Subject, Subscription } from 'rxjs' import { concatMap, map, switchMap, tap } from 'rxjs/operators' -import { from, Subscription } from 'rxjs' -import { VideoChannel } from '@app/shared/video-channel/video-channel.model' -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 { Component, OnDestroy, OnInit } from '@angular/core' +import { ComponentPagination, hasMoreItems, ScreenService, User, UserService } from '@app/core' +import { Account, AccountService, Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' +import { VideoSortField } from '@shared/models' @Component({ selector: 'my-account-video-channels', @@ -24,29 +17,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() + + 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 +50,9 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy { this.loadMoreChannels() }) + + this.userService.getAnonymousOrLoggedUser() + .subscribe(user => this.userMiniature = user) } ngOnDestroy () { @@ -68,18 +66,23 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy { switchMap(res => from(res.data)), concatMap(videoChannel => { return this.videoService.getVideoChannelVideos(videoChannel, this.videosPagination, this.videosSort) - .pipe(map(data => ({ videoChannel, videos: data.videos }))) + .pipe(map(data => ({ videoChannel, videos: data.data }))) }) ) .subscribe(({ videoChannel, videos }) => { 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 +92,8 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy { this.loadMoreChannels() } + + getVideoChannelLink (videoChannel: VideoChannel) { + return [ '/video-channels', videoChannel.nameWithHost ] + } }