diff options
Diffstat (limited to 'client/src/app/shared/shared-support-modal/support-modal.component.ts')
-rw-r--r-- | client/src/app/shared/shared-support-modal/support-modal.component.ts | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/client/src/app/shared/shared-support-modal/support-modal.component.ts b/client/src/app/shared/shared-support-modal/support-modal.component.ts new file mode 100644 index 000000000..ae603c7a8 --- /dev/null +++ b/client/src/app/shared/shared-support-modal/support-modal.component.ts | |||
@@ -0,0 +1,40 @@ | |||
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 | } | ||