]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
Fix client lint
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-edit / video-add-components / video-upload.component.ts
index ec027f257e98b7583312063b7cca14742a89bc48..b8cb4fa1e5904b52c6c6fbdf399c13d5c53c989e 100644 (file)
@@ -7,8 +7,7 @@ import { genericUploadErrorHandler, scrollToTop } from '@app/helpers'
 import { FormValidatorService } from '@app/shared/shared-forms'
 import { BytesPipe, Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
 import { LoadingBarService } from '@ngx-loading-bar/core'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
-import { VideoPrivacy } from '@shared/models'
+import { HttpStatusCode, VideoPrivacy } from '@shared/models'
 import { UploaderXFormData } from './uploaderx-form-data'
 import { VideoSend } from './video-send'
 
@@ -45,6 +44,8 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
   error: string
   enableRetryAfterError: boolean
 
+  schedulePublicationPossible = false
+
   // So that it can be accessed in the template
   protected readonly BASE_VIDEO_UPLOAD_URL = VideoService.BASE_VIDEO_URL + 'upload-resumable'
 
@@ -85,6 +86,46 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
     return this.serverConfig.video.file.extensions.join(', ')
   }
 
+  ngOnInit () {
+    super.ngOnInit()
+
+    this.userService.getMyVideoQuotaUsed()
+        .subscribe(data => {
+          this.userVideoQuotaUsed = data.videoQuotaUsed
+          this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
+        })
+
+    this.resumableUploadService.events
+      .subscribe(state => this.onUploadVideoOngoing(state))
+
+    this.schedulePublicationPossible = this.videoPrivacies.some(p => p.id === VideoPrivacy.PRIVATE)
+  }
+
+  ngAfterViewInit () {
+    this.hooks.runAction('action:video-upload.init', 'video-edit')
+  }
+
+  ngOnDestroy () {
+    this.cancelUpload()
+  }
+
+  canDeactivate () {
+    let text = ''
+
+    if (this.videoUploaded === true) {
+      // FIXME: cannot concatenate strings using $localize
+      text = $localize`Your video was uploaded to your account and is private.` + ' ' +
+        $localize`But associated data (tags, description...) will be lost, are you sure you want to leave this page?`
+    } else {
+      text = $localize`Your video is not uploaded yet, are you sure you want to leave this page?`
+    }
+
+    return {
+      canDeactivate: !this.isUploadingVideo,
+      text
+    }
+  }
+
   onUploadVideoOngoing (state: UploadState) {
     switch (state.status) {
       case 'error':
@@ -133,44 +174,6 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
     }
   }
 
-  ngOnInit () {
-    super.ngOnInit()
-
-    this.userService.getMyVideoQuotaUsed()
-        .subscribe(data => {
-          this.userVideoQuotaUsed = data.videoQuotaUsed
-          this.userVideoQuotaUsedDaily = data.videoQuotaUsedDaily
-        })
-
-    this.resumableUploadService.events
-      .subscribe(state => this.onUploadVideoOngoing(state))
-  }
-
-  ngAfterViewInit () {
-    this.hooks.runAction('action:video-upload.init', 'video-edit')
-  }
-
-  ngOnDestroy () {
-    this.cancelUpload()
-  }
-
-  canDeactivate () {
-    let text = ''
-
-    if (this.videoUploaded === true) {
-      // FIXME: cannot concatenate strings using $localize
-      text = $localize`Your video was uploaded to your account and is private.` + ' ' +
-        $localize`But associated data (tags, description...) will be lost, are you sure you want to leave this page?`
-    } else {
-      text = $localize`Your video is not uploaded yet, are you sure you want to leave this page?`
-    }
-
-    return {
-      canDeactivate: !this.isUploadingVideo,
-      text
-    }
-  }
-
   onFileDropped (files: FileList) {
     this.videofileInput.nativeElement.files = files
 
@@ -237,8 +240,8 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
     this.isUpdatingVideo = true
 
     this.updateVideoAndCaptions(video)
-        .subscribe(
-          () => {
+        .subscribe({
+          next: () => {
             this.isUpdatingVideo = false
             this.isUploadingVideo = false
 
@@ -246,12 +249,12 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
             this.router.navigateByUrl(Video.buildWatchUrl(video))
           },
 
-          err => {
+          error: err => {
             this.error = err.message
             scrollToTop()
             console.error(err)
           }
-        )
+        })
   }
 
   private getInputVideoFile () {
@@ -265,7 +268,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
       downloadEnabled: true,
       channelId: this.firstStepChannelId,
       nsfw: this.serverConfig.instance.isNSFW,
-      privacy: VideoPrivacy.PRIVATE.toString(),
+      privacy: this.highestPrivacy.toString(),
       filename: file.name,
       previewfile: previewfile as any
     }