import { from, Subject, Subscription } from 'rxjs'
import { concatMap, map, switchMap, tap } from 'rxjs/operators'
import { Component, OnDestroy, OnInit } from '@angular/core'
import { from, Subject, Subscription } from 'rxjs'
import { concatMap, map, switchMap, tap } from 'rxjs/operators'
import { Component, OnDestroy, OnInit } from '@angular/core'
-import { ComponentPagination, hasMoreItems, ScreenService, User, UserService } from '@app/core'
+import { ComponentPagination, hasMoreItems, MarkdownService, User, UserService } from '@app/core'
import { Account, AccountService, Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
import { Account, AccountService, Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
-import { VideoSortField } from '@shared/models'
+import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature'
+import { NSFWPolicyType, VideoSortField } from '@shared/models'
+import { SimpleMemoize } from '@app/helpers'
export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
account: Account
videoChannels: VideoChannel[] = []
export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
account: Account
videoChannels: VideoChannel[] = []
private accountService: AccountService,
private videoChannelService: VideoChannelService,
private videoService: VideoService,
private accountService: AccountService,
private videoChannelService: VideoChannelService,
private videoService: VideoService,
switchMap(res => from(res.data)),
concatMap(videoChannel => {
switchMap(res => from(res.data)),
concatMap(videoChannel => {
- return this.videoService.getVideoChannelVideos(videoChannel, this.videosPagination, this.videosSort)
- .pipe(map(data => ({ videoChannel, videos: data.data })))
+ const options = {
+ videoChannel,
+ videoPagination: this.videosPagination,
+ sort: this.videosSort,
+ nsfwPolicy: this.nsfwPolicy
+ }
+
+ return this.videoService.getVideoChannelVideos(options)
+ .pipe(map(data => ({ videoChannel, videos: data.data, total: data.total })))
- .subscribe(({ videoChannel, videos }) => {
+ .subscribe(async ({ videoChannel, videos, total }) => {
+ this.channelsDescriptionHTML[videoChannel.id] = await this.markdown.textMarkdownToHTML({
+ markdown: videoChannel.description,
+ withEmoji: true,
+ withHtml: true
+ })
+
- const numberOfVideos = this.screenService.getNumberOfAvailableMiniatures()
+ const obj = this.videos[videoChannel.id]
+ if (!obj) return []
+
+ return obj.videos
+ }
+
+ getTotalVideosOf (videoChannel: VideoChannel) {
+ const obj = this.videos[videoChannel.id]
+ if (!obj) return undefined
+
+ return obj.total
+ }