]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+accounts/account-about/account-about.component.ts
Handle markdown in account/video channel pages
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-about / account-about.component.ts
1 import { Component, OnInit, OnDestroy } from '@angular/core'
2 import { ActivatedRoute } from '@angular/router'
3 import { Account } from '@app/shared/account/account.model'
4 import { AccountService } from '@app/shared/account/account.service'
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-account-about',
11 templateUrl: './account-about.component.html',
12 styleUrls: [ './account-about.component.scss' ]
13 })
14 export class AccountAboutComponent implements OnInit, OnDestroy {
15 account: Account
16 descriptionHTML = ''
17
18 private accountSub: Subscription
19
20 constructor (
21 private route: ActivatedRoute,
22 private i18n: I18n,
23 private accountService: AccountService,
24 private markdownService: MarkdownService
25 ) { }
26
27 ngOnInit () {
28 // Parent get the account for us
29 this.accountSub = this.accountService.accountLoaded
30 .subscribe(account => {
31 this.account = account
32 this.descriptionHTML = this.markdownService.textMarkdownToHTML(this.account.description)
33 })
34 }
35
36 ngOnDestroy () {
37 if (this.accountSub) this.accountSub.unsubscribe()
38 }
39
40 getAccountDescription () {
41 if (this.descriptionHTML) return this.descriptionHTML
42
43 return this.i18n('No description')
44 }
45 }