]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+accounts/account-video-channels/account-video-channels.component.ts
Add Podcast RSS feeds (#5487)
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-video-channels / account-video-channels.component.ts
index 96d1e0f85a8453899895eb78f5f3fbbc98d2d306..631444398cc73e889fe1fc0a3966bad150dfb356 100644 (file)
@@ -1,10 +1,11 @@
 import { from, Subject, Subscription } from 'rxjs'
 import { concatMap, map, switchMap, tap } from 'rxjs/operators'
 import { Component, OnDestroy, OnInit } from '@angular/core'
-import { ComponentPagination, hasMoreItems, MarkdownService, 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 { NSFWPolicyType, VideoSortField } from '@shared/models'
 import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature'
+import { NSFWPolicyType, VideoSortField } from '@shared/models'
+import { SimpleMemoize } from '@app/helpers'
 
 @Component({
   selector: 'my-account-video-channels',
@@ -62,6 +63,7 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
     this.accountSub = this.accountService.accountLoaded
         .subscribe(account => {
           this.account = account
+          this.videoChannels = []
 
           this.loadMoreChannels()
         })
@@ -79,9 +81,17 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
   }
 
   loadMoreChannels () {
-    this.videoChannelService.listAccountVideoChannels(this.account, this.channelPagination)
+    const options = {
+      account: this.account,
+      componentPagination: this.channelPagination,
+      sort: '-updatedAt'
+    }
+
+    this.videoChannelService.listAccountVideoChannels(options)
       .pipe(
-        tap(res => this.channelPagination.totalItems = res.total),
+        tap(res => {
+          this.channelPagination.totalItems = res.total
+        }),
         switchMap(res => from(res.data)),
         concatMap(videoChannel => {
           const options = {
@@ -96,7 +106,11 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
         })
       )
       .subscribe(async ({ videoChannel, videos, total }) => {
-        this.channelsDescriptionHTML[videoChannel.id] = await this.markdown.textMarkdownToHTML(videoChannel.description)
+        this.channelsDescriptionHTML[videoChannel.id] = await this.markdown.textMarkdownToHTML({
+          markdown: videoChannel.description,
+          withEmoji: true,
+          withHtml: true
+        })
 
         this.videoChannels.push(videoChannel)
 
@@ -107,14 +121,14 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
   }
 
   getVideosOf (videoChannel: VideoChannel) {
-    const obj = this.videos[ videoChannel.id ]
+    const obj = this.videos[videoChannel.id]
     if (!obj) return []
 
     return obj.videos
   }
 
   getTotalVideosOf (videoChannel: VideoChannel) {
-    const obj = this.videos[ videoChannel.id ]
+    const obj = this.videos[videoChannel.id]
     if (!obj) return undefined
 
     return obj.total
@@ -132,6 +146,7 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy {
     this.loadMoreChannels()
   }
 
+  @SimpleMemoize()
   getVideoChannelLink (videoChannel: VideoChannel) {
     return [ '/c', videoChannel.nameWithHost ]
   }