]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+video-channels/video-channel-about/video-channel-about.component.ts
Handle markdown in account/video channel pages
[github/Chocobozzz/PeerTube.git] / client / src / app / +video-channels / video-channel-about / video-channel-about.component.ts
1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute } from '@angular/router'
3 import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
4 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
5 import { I18n } from '@ngx-translate/i18n-polyfill'
6 import { Subscription } from 'rxjs'
7 import { MarkdownService } from '@app/videos/shared'
8
9 @Component({
10 selector: 'my-video-channel-about',
11 templateUrl: './video-channel-about.component.html',
12 styleUrls: [ './video-channel-about.component.scss' ]
13 })
14 export class VideoChannelAboutComponent implements OnInit, OnDestroy {
15 videoChannel: VideoChannel
16 descriptionHTML = ''
17 supportHTML = ''
18
19 private videoChannelSub: Subscription
20
21 constructor (
22 private route: ActivatedRoute,
23 private i18n: I18n,
24 private videoChannelService: VideoChannelService,
25 private markdownService: MarkdownService
26 ) { }
27
28 ngOnInit () {
29 // Parent get the video channel for us
30 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
31 .subscribe(videoChannel => {
32 this.videoChannel = videoChannel
33
34 this.descriptionHTML = this.markdownService.textMarkdownToHTML(this.videoChannel.description)
35 this.supportHTML = this.markdownService.enhancedMarkdownToHTML(this.videoChannel.support)
36 })
37 }
38
39 ngOnDestroy () {
40 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
41 }
42
43 getVideoChannelDescription () {
44 if (this.descriptionHTML) return this.descriptionHTML
45
46 return this.i18n('No description')
47 }
48 }