]>
Commit | Line | Data |
---|---|---|
100d9ce2 C |
1 | import { Component, Input, ViewChild } from '@angular/core' |
2 | import { MarkdownService } from '@app/core' | |
3 | import { VideoDetails } from '@app/shared/shared-main' | |
4 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | |
5 | import { VideoChannel } from '@shared/models' | |
6 | ||
7 | @Component({ | |
8 | selector: 'my-support-modal', | |
9 | templateUrl: './support-modal.component.html', | |
10 | styleUrls: [ './support-modal.component.scss' ] | |
11 | }) | |
12 | export class SupportModalComponent { | |
13 | @Input() video: VideoDetails = null | |
14 | @Input() videoChannel: VideoChannel = null | |
15 | ||
16 | @ViewChild('modal', { static: true }) modal: NgbModal | |
17 | ||
18 | htmlSupport = '' | |
19 | displayName = '' | |
20 | ||
21 | constructor ( | |
22 | private markdownService: MarkdownService, | |
23 | private modalService: NgbModal | |
24 | ) { } | |
25 | ||
26 | show () { | |
27 | const modalRef = this.modalService.open(this.modal, { centered: true }) | |
28 | ||
29 | const support = this.video?.support || this.videoChannel.support | |
30 | ||
31 | this.markdownService.enhancedMarkdownToHTML(support) | |
32 | .then(r => this.htmlSupport = r) | |
33 | ||
34 | this.displayName = this.video | |
35 | ? this.video.channel.displayName | |
36 | : this.videoChannel.displayName | |
37 | ||
38 | return modalRef | |
39 | } | |
40 | } |