aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal/video-caption-edit-modal.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-02-28 13:42:48 +0100
committerChocobozzz <chocobozzz@cpy.re>2022-02-28 14:29:01 +0100
commit70a8e50a5d3df90cba615559b5aaba1536356f5a (patch)
tree66289e1d18baf2165e862584539a57c7e89eda41 /client/src/app/+videos/+video-edit/shared/video-caption-edit-modal/video-caption-edit-modal.component.ts
parent57d74ec83d64daaf2efc6a3dad8adbcfe1f59415 (diff)
downloadPeerTube-70a8e50a5d3df90cba615559b5aaba1536356f5a.tar.gz
PeerTube-70a8e50a5d3df90cba615559b5aaba1536356f5a.tar.zst
PeerTube-70a8e50a5d3df90cba615559b5aaba1536356f5a.zip
Cleanup subtitle edition PR
Diffstat (limited to 'client/src/app/+videos/+video-edit/shared/video-caption-edit-modal/video-caption-edit-modal.component.ts')
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-caption-edit-modal/video-caption-edit-modal.component.ts19
1 files changed, 5 insertions, 14 deletions
diff --git a/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal/video-caption-edit-modal.component.ts b/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal/video-caption-edit-modal.component.ts
index d2232a38e..f74f3c5ea 100644
--- a/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal/video-caption-edit-modal.component.ts
+++ b/client/src/app/+videos/+video-edit/shared/video-caption-edit-modal/video-caption-edit-modal.component.ts
@@ -1,5 +1,4 @@
1import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' 1import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
2
3import { VIDEO_CAPTION_FILE_CONTENT_VALIDATOR } from '@app/shared/form-validators/video-captions-validators' 2import { VIDEO_CAPTION_FILE_CONTENT_VALIDATOR } from '@app/shared/form-validators/video-captions-validators'
4import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' 3import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
5import { VideoCaptionEdit, VideoCaptionService, VideoCaptionWithPathEdit } from '@app/shared/shared-main' 4import { VideoCaptionEdit, VideoCaptionService, VideoCaptionWithPathEdit } from '@app/shared/shared-main'
@@ -23,7 +22,6 @@ export class VideoCaptionEditModalComponent extends FormReactive implements OnIn
23 22
24 videoCaptionLanguages: VideoConstant<string>[] = [] 23 videoCaptionLanguages: VideoConstant<string>[] = []
25 private openedModal: NgbModalRef 24 private openedModal: NgbModalRef
26 private closingModal = false
27 25
28 constructor ( 26 constructor (
29 protected formValidatorService: FormValidatorService, 27 protected formValidatorService: FormValidatorService,
@@ -44,25 +42,21 @@ export class VideoCaptionEditModalComponent extends FormReactive implements OnIn
44 42
45 loadCaptionContent () { 43 loadCaptionContent () {
46 const { captionPath } = this.videoCaption 44 const { captionPath } = this.videoCaption
47 if (captionPath) { 45 if (!captionPath) return
48 this.videoCaptionService.getCaptionContent({ 46
49 captionPath 47 this.videoCaptionService.getCaptionContent({ captionPath })
50 }).subscribe((res) => { 48 .subscribe(res => {
51 this.form.patchValue({ 49 this.form.patchValue({
52 captionFileContent: res 50 captionFileContent: res
53 }) 51 })
54 }) 52 })
55 }
56 } 53 }
57 54
58 show () { 55 show () {
59 this.closingModal = false
60
61 this.openedModal = this.modalService.open(this.modal, { centered: true, keyboard: false }) 56 this.openedModal = this.modalService.open(this.modal, { centered: true, keyboard: false })
62 } 57 }
63 58
64 hide () { 59 hide () {
65 this.closingModal = true
66 this.openedModal.close() 60 this.openedModal.close()
67 } 61 }
68 62
@@ -70,14 +64,11 @@ export class VideoCaptionEditModalComponent extends FormReactive implements OnIn
70 this.hide() 64 this.hide()
71 } 65 }
72 66
73 isReplacingExistingCaption () {
74 return true
75 }
76
77 updateCaption () { 67 updateCaption () {
78 const format = 'vtt' 68 const format = 'vtt'
79 const languageId = this.videoCaption.language.id 69 const languageId = this.videoCaption.language.id
80 const languageObject = this.videoCaptionLanguages.find(l => l.id === languageId) 70 const languageObject = this.videoCaptionLanguages.find(l => l.id === languageId)
71
81 this.captionEdited.emit({ 72 this.captionEdited.emit({
82 language: languageObject, 73 language: languageObject,
83 captionfile: new File([ this.form.value['captionFileContent'] ], `${languageId}.${format}`, { 74 captionfile: new File([ this.form.value['captionFileContent'] ], `${languageId}.${format}`, {