]>
Commit | Line | Data |
---|---|---|
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 | ||
6 | @Component({ | |
7 | selector: 'my-account-about', | |
8 | templateUrl: './account-about.component.html', | |
9 | styleUrls: [ './account-about.component.scss' ] | |
10 | }) | |
11 | export class AccountAboutComponent implements OnInit, OnDestroy { | |
12 | account: Account | |
13 | descriptionHTML = '' | |
14 | ||
15 | private accountSub: Subscription | |
16 | ||
17 | constructor ( | |
18 | private accountService: AccountService, | |
19 | private markdownService: MarkdownService | |
20 | ) { } | |
21 | ||
22 | ngOnInit () { | |
23 | // Parent get the account for us | |
24 | this.accountSub = this.accountService.accountLoaded | |
25 | .subscribe(async account => { | |
26 | this.account = account | |
27 | this.descriptionHTML = await this.markdownService.textMarkdownToHTML(this.account.description, true) | |
28 | }) | |
29 | } | |
30 | ||
31 | ngOnDestroy () { | |
32 | if (this.accountSub) this.accountSub.unsubscribe() | |
33 | } | |
34 | ||
35 | getAccountDescription () { | |
36 | if (this.descriptionHTML) return this.descriptionHTML | |
37 | ||
38 | return $localize`No description` | |
39 | } | |
40 | } |