]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix wait transcoding checkbox display
authorChocobozzz <me@florianbigard.com>
Tue, 26 Jan 2021 09:56:55 +0000 (10:56 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 26 Jan 2021 09:56:55 +0000 (10:56 +0100)
client/src/app/+videos/+video-edit/shared/video-edit.component.html
client/src/app/+videos/+video-edit/shared/video-edit.component.ts
client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.html
client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts
client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html
client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
client/src/app/+videos/+video-edit/video-update.component.html
client/src/app/+videos/+video-edit/video-update.component.ts

index 9c2aea526dc062a19f63d75fdd46d85ea522a3e2..6208ab69bf5daa98d996100179f26adbb02d3d76 100644 (file)
               </ng-template>
             </my-peertube-checkbox>
 
-            <my-peertube-checkbox *ngIf="isWaitTranscodingDisplayed()" inputName="waitTranscoding" formControlName="waitTranscoding" helpPlacement="bottom-right">
+            <my-peertube-checkbox *ngIf="waitTranscodingEnabled" inputName="waitTranscoding" formControlName="waitTranscoding" helpPlacement="bottom-right">
               <ng-template ptTemplate="label">
                 <ng-container i18n>Publish after transcoding</ng-container>
               </ng-template>
 </div>
 
 <my-video-caption-add-modal
-  #videoCaptionAddModal [existingCaptions]="existingCaptions" [serverConfig]="serverConfig" (captionAdded)="onCaptionAdded($event)"
+  #videoCaptionAddModal [existingCaptions]="getExistingCaptions()" [serverConfig]="serverConfig" (captionAdded)="onCaptionAdded($event)"
 ></my-video-caption-add-modal>
index 5294a57a1fa560e4d9e216a28c70659307e3d1b1..80b5dce462ac78a4d2e9a0e5a33c04f6bcb32adb 100644 (file)
@@ -96,22 +96,6 @@ export class VideoEditComponent implements OnInit, OnDestroy {
     this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat()
   }
 
-  get existingCaptions () {
-    return this.videoCaptions
-               .filter(c => c.action !== 'REMOVE')
-               .map(c => c.language.id)
-  }
-
-  isWaitTranscodingDisplayed () {
-    if (!this.waitTranscodingEnabled) return false
-
-    if (this.liveVideo) {
-      return this.form.value['saveReplay'] === true
-    }
-
-    return true
-  }
-
   updateForm () {
     const defaultValues: any = {
       nsfw: 'false',
@@ -217,6 +201,12 @@ export class VideoEditComponent implements OnInit, OnDestroy {
     if (this.schedulerInterval) clearInterval(this.schedulerInterval)
   }
 
+  getExistingCaptions () {
+    return this.videoCaptions
+               .filter(c => c.action !== 'REMOVE')
+               .map(c => c.language.id)
+  }
+
   onCaptionAdded (caption: VideoCaptionEdit) {
     const existingCaption = this.videoCaptions.find(c => c.language.id === caption.language.id)
 
index 17c37d42bd854b2393e96b77c75a19ebbfe4861e..fddb08e0b89b25f240c46ac888192f251e6a984a 100644 (file)
@@ -36,7 +36,7 @@
 <form [hidden]="!isInUpdateForm" novalidate [formGroup]="form">
   <my-video-edit
     [form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions"
-    [schedulePublicationPossible]="false" [waitTranscodingEnabled]="false"
+    [schedulePublicationPossible]="false" [waitTranscodingEnabled]="isWaitTranscodingEnabled()"
     [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels" [liveVideo]="liveVideo"
     type="go-live"
   ></my-video-edit>
index 67d055f066d3de1dad3d5ae994e2202f82e35cd8..8780ca5678e641095fa4e5f6668fc59606877b79 100644 (file)
@@ -137,6 +137,10 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon
     return this.serverConfig.live.maxDuration / 1000
   }
 
+  isWaitTranscodingEnabled () {
+    return this.form.value['saveReplay'] === true
+  }
+
   private fetchVideoLive () {
     this.liveVideoService.getVideoLive(this.videoId)
       .subscribe(
index deea3daf9b58a5cb253c787646ac5004a4de5118..4c0b098940e9dad610b091487616d47c9de1cb33 100644 (file)
@@ -84,7 +84,7 @@
   <my-video-edit
     [form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions"
     [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
-    [waitTranscodingEnabled]="waitTranscodingEnabled"
+    [waitTranscodingEnabled]="true"
     type="upload"
   ></my-video-edit>
 
index cafb030b9930074467a1fed1ee228b254dd59352..ca21b61cd918bb7c81432714f3875751642c452a 100644 (file)
@@ -44,7 +44,6 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
   }
   formData: FormData
 
-  waitTranscodingEnabled = true
   previewfileUpload: File
 
   error: string
@@ -163,11 +162,6 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
     if (nameWithoutExtension.length < 3) name = videofile.name
     else name = nameWithoutExtension
 
-    // Force user to wait transcoding for unsupported video types in web browsers
-    if (!videofile.name.endsWith('.mp4') && !videofile.name.endsWith('.webm') && !videofile.name.endsWith('.ogv')) {
-      this.waitTranscodingEnabled = false
-    }
-
     const nsfw = this.serverConfig.instance.isNSFW
     const waitTranscoding = true
     const commentsEnabled = true
index f290fd136934631ef74e8321590128c55773a5bb..41501714f68a04c10ee085de4641de3c0c38adb9 100644 (file)
@@ -9,7 +9,7 @@
     <my-video-edit
       [form]="form" [formErrors]="formErrors" [schedulePublicationPossible]="schedulePublicationPossible"
       [validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
-      [videoCaptions]="videoCaptions" [waitTranscodingEnabled]="waitTranscodingEnabled"
+      [videoCaptions]="videoCaptions" [waitTranscodingEnabled]="isWaitTranscodingEnabled()"
       type="update" (pluginFieldsAdded)="hydratePluginFieldsFromVideo()"
       [liveVideo]="liveVideo"
     ></my-video-edit>
index 30c82343bc4d1285ad931d4346a8711fa5f743f7..e2331c148ea8a072cff803bdb973bfc4e472f0df 100644 (file)
@@ -17,6 +17,7 @@ import { hydrateFormFromVideo } from './shared/video-edit-utils'
 })
 export class VideoUpdateComponent extends FormReactive implements OnInit {
   video: VideoEdit
+  videoDetails: VideoDetails
   userVideoChannels: SelectChannelItem[] = []
   videoCaptions: VideoCaptionEdit[] = []
   liveVideo: LiveVideo
@@ -47,17 +48,14 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
         .pipe(map(data => data.videoData))
         .subscribe(({ video, videoChannels, videoCaptions, liveVideo }) => {
           this.video = new VideoEdit(video)
+          this.videoDetails = video
+
           this.userVideoChannels = videoChannels
           this.videoCaptions = videoCaptions
           this.liveVideo = liveVideo
 
           this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
 
-          const videoFiles = (video as VideoDetails).getFiles()
-          if (videoFiles.length > 1) { // Already transcoded
-            this.waitTranscodingEnabled = false
-          }
-
           // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
           setTimeout(() => {
             hydrateFormFromVideo(this.form, this.video, true)
@@ -106,6 +104,18 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
     return this.form.valid
   }
 
+  isWaitTranscodingEnabled () {
+    if (this.videoDetails.getFiles().length > 1) { // Already transcoded
+      return false
+    }
+
+    if (this.liveVideo && this.form.value['saveReplay'] !== true) {
+      return false
+    }
+
+    return true
+  }
+
   update () {
     if (this.checkForm() === false
       || this.isUpdatingVideo === true) {