From 3ce48a0cd062d9ff64d9411d702453503a49f3b1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 30 Jul 2021 11:24:38 +0200 Subject: [PATCH] Hide schedule privacy if private does not exist --- .../video-upload.component.html | 2 +- .../video-upload.component.ts | 80 ++++++++++--------- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html index 86a779f8a..14cd06fcf 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html @@ -96,7 +96,7 @@ diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts index 627de33c0..d8d20a249 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts @@ -45,6 +45,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 +87,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 +175,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