]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+video-channels/video-channel-about/video-channel-about.component.ts
Lazy import some modules
[github/Chocobozzz/PeerTube.git] / client / src / app / +video-channels / video-channel-about / video-channel-about.component.ts
index c5fd442c6c4663b0e7e07fcba3e5f05b2d09af56..11f9391e124e09861357acd91ec4765d9421ed5c 100644 (file)
@@ -1,31 +1,45 @@
-import { Component, OnInit } from '@angular/core'
-import { ActivatedRoute } from '@angular/router'
+import { Component, OnDestroy, OnInit } from '@angular/core'
 import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
 import { I18n } from '@ngx-translate/i18n-polyfill'
+import { Subscription } from 'rxjs'
+import { MarkdownService } from '@app/shared/renderer'
 
 @Component({
   selector: 'my-video-channel-about',
   templateUrl: './video-channel-about.component.html',
   styleUrls: [ './video-channel-about.component.scss' ]
 })
-export class VideoChannelAboutComponent implements OnInit {
+export class VideoChannelAboutComponent implements OnInit, OnDestroy {
   videoChannel: VideoChannel
+  descriptionHTML = ''
+  supportHTML = ''
+
+  private videoChannelSub: Subscription
 
   constructor (
-    private route: ActivatedRoute,
     private i18n: I18n,
-    private videoChannelService: VideoChannelService
+    private videoChannelService: VideoChannelService,
+    private markdownService: MarkdownService
   ) { }
 
   ngOnInit () {
     // Parent get the video channel for us
-    this.videoChannelService.videoChannelLoaded
-      .subscribe(videoChannel => this.videoChannel = videoChannel)
+    this.videoChannelSub = this.videoChannelService.videoChannelLoaded
+      .subscribe(async videoChannel => {
+        this.videoChannel = videoChannel
+
+        this.descriptionHTML = await this.markdownService.textMarkdownToHTML(this.videoChannel.description)
+        this.supportHTML = await this.markdownService.enhancedMarkdownToHTML(this.videoChannel.support)
+      })
+  }
+
+  ngOnDestroy () {
+    if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
   }
 
   getVideoChannelDescription () {
-    if (this.videoChannel.description) return this.videoChannel.description
+    if (this.descriptionHTML) return this.descriptionHTML
 
     return this.i18n('No description')
   }