]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Cleanup subtitle edition PR
authorChocobozzz <me@florianbigard.com>
Mon, 28 Feb 2022 12:42:48 +0000 (13:42 +0100)
committerChocobozzz <chocobozzz@cpy.re>
Mon, 28 Feb 2022 13:29:01 +0000 (14:29 +0100)
client/src/app/+videos/+video-edit/shared/video-caption-edit-modal/video-caption-edit-modal.component.html
client/src/app/+videos/+video-edit/shared/video-caption-edit-modal/video-caption-edit-modal.component.ts
client/src/app/+videos/+video-edit/shared/video-edit.component.ts
client/src/app/shared/shared-main/video-caption/video-caption.service.ts

index 4543b93d83902347e26da4df7454e508edd91618..be6f676c24fc8bab53ba8a148ea198f10be78c2b 100644 (file)
@@ -17,7 +17,7 @@
       </textarea>
 
       <div *ngIf="formErrors.captionFileContent" class="form-error">
-        {{ formErrors.description }}
+        {{ formErrors.captionFileContent }}
       </div>
     </div>
 
index d2232a38e3dd5de333ac643acb229c8318d7b284..f74f3c5ea0439e71f7b181c88b2ada64bf2aa1db 100644 (file)
@@ -1,5 +1,4 @@
 import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
-
 import { VIDEO_CAPTION_FILE_CONTENT_VALIDATOR } from '@app/shared/form-validators/video-captions-validators'
 import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { VideoCaptionEdit, VideoCaptionService, VideoCaptionWithPathEdit } from '@app/shared/shared-main'
@@ -23,7 +22,6 @@ export class VideoCaptionEditModalComponent extends FormReactive implements OnIn
 
   videoCaptionLanguages: VideoConstant<string>[] = []
   private openedModal: NgbModalRef
-  private closingModal = false
 
   constructor (
     protected formValidatorService: FormValidatorService,
@@ -44,25 +42,21 @@ export class VideoCaptionEditModalComponent extends FormReactive implements OnIn
 
   loadCaptionContent () {
     const { captionPath } = this.videoCaption
-    if (captionPath) {
-      this.videoCaptionService.getCaptionContent({
-        captionPath
-      }).subscribe((res) => {
+    if (!captionPath) return
+
+    this.videoCaptionService.getCaptionContent({ captionPath })
+      .subscribe(res => {
         this.form.patchValue({
           captionFileContent: res
         })
       })
-    }
   }
 
   show () {
-    this.closingModal = false
-
     this.openedModal = this.modalService.open(this.modal, { centered: true, keyboard: false })
   }
 
   hide () {
-    this.closingModal = true
     this.openedModal.close()
   }
 
@@ -70,14 +64,11 @@ export class VideoCaptionEditModalComponent extends FormReactive implements OnIn
     this.hide()
   }
 
-  isReplacingExistingCaption () {
-    return true
-  }
-
   updateCaption () {
     const format = 'vtt'
     const languageId = this.videoCaption.language.id
     const languageObject = this.videoCaptionLanguages.find(l => l.id === languageId)
+
     this.captionEdited.emit({
       language: languageObject,
       captionfile: new File([ this.form.value['captionFileContent'] ], `${languageId}.${format}`, {
index 0f4d0619bfef34483669e7868995dc08d1723015..2801fc519462b7985a46b505e73de4a4c9a74f2d 100644 (file)
@@ -59,7 +59,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
   @Input() userVideoChannels: SelectChannelItem[] = []
   @Input() forbidScheduledPublication = true
 
-  @Input() videoCaptions: (VideoCaptionWithPathEdit)[] = []
+  @Input() videoCaptions: VideoCaptionWithPathEdit[] = []
 
   @Input() waitTranscodingEnabled = true
   @Input() type: VideoEditType
index 67eb09e4d5e7bcfcc3be9a575ab2ab16b66106ff..00ebe5bc6cef785c65d0c23f739b71d77e6612ca 100644 (file)
@@ -7,8 +7,8 @@ import { objectToFormData, sortBy } from '@app/helpers'
 import { VideoService } from '@app/shared/shared-main/video'
 import { peertubeTranslate } from '@shared/core-utils/i18n'
 import { ResultList, VideoCaption } from '@shared/models'
-import { VideoCaptionEdit } from './video-caption-edit.model'
 import { environment } from '../../../../environments/environment'
+import { VideoCaptionEdit } from './video-caption-edit.model'
 
 @Injectable()
 export class VideoCaptionService {
@@ -69,6 +69,6 @@ export class VideoCaptionService {
   }
 
   getCaptionContent ({ captionPath }: Pick<VideoCaption, 'captionPath'>) {
-    return this.authHttp.get(`${environment.originServerUrl}${captionPath}`, { responseType: 'text' })
+    return this.authHttp.get(environment.originServerUrl + captionPath, { responseType: 'text' })
   }
 }