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