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