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