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