]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+accounts/account-about/account-about.component.ts
8c01e4007d270018a5011409375d69f72bdd295e
[github/Chocobozzz/PeerTube.git] / client / src / app / +accounts / account-about / account-about.component.ts
1 import { Subscription } from 'rxjs'
2 import { Component, OnDestroy, OnInit } from '@angular/core'
3 import { MarkdownService } from '@app/core'
4 import { Account, AccountService } from '@app/shared/shared-main'
5 import { I18n } from '@ngx-translate/i18n-polyfill'
6
7 @Component({
8 selector: 'my-account-about',
9 templateUrl: './account-about.component.html',
10 styleUrls: [ './account-about.component.scss' ]
11 })
12 export class AccountAboutComponent implements OnInit, OnDestroy {
13 account: Account
14 descriptionHTML = ''
15
16 private accountSub: Subscription
17
18 constructor (
19 private i18n: I18n,
20 private accountService: AccountService,
21 private markdownService: MarkdownService
22 ) { }
23
24 ngOnInit () {
25 // Parent get the account for us
26 this.accountSub = this.accountService.accountLoaded
27 .subscribe(async account => {
28 this.account = account
29 this.descriptionHTML = await this.markdownService.textMarkdownToHTML(this.account.description, true)
30 })
31 }
32
33 ngOnDestroy () {
34 if (this.accountSub) this.accountSub.unsubscribe()
35 }
36
37 getAccountDescription () {
38 if (this.descriptionHTML) return this.descriptionHTML
39
40 return this.i18n('No description')
41 }
42 }