aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-support-modal/support-modal.component.ts
blob: 08e997f7bfeb9b52cc5972069e941bfa9d124b11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Component, Input, ViewChild } from '@angular/core'
import { MarkdownService } from '@app/core'
import { VideoDetails } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { VideoChannel } from '@shared/models'

@Component({
  selector: 'my-support-modal',
  templateUrl: './support-modal.component.html'
})
export class SupportModalComponent {
  @Input() video: VideoDetails = null
  @Input() videoChannel: VideoChannel = null

  @ViewChild('modal', { static: true }) modal: NgbModal

  htmlSupport = ''
  displayName = ''

  constructor (
    private markdownService: MarkdownService,
    private modalService: NgbModal
  ) { }

  show () {
    const modalRef = this.modalService.open(this.modal, { centered: true })

    const support = this.video?.support || this.videoChannel.support

    this.markdownService.enhancedMarkdownToHTML(support)
      .then(r => {
        this.htmlSupport = r
      })

    this.displayName = this.video
      ? this.video.channel.displayName
      : this.videoChannel.displayName

    return modalRef
  }
}