Skip to content

Commit

Permalink
Fix scheduled publication on upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz committed Feb 7, 2022
1 parent 4393b25 commit 4afec73
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 19 deletions.
18 changes: 10 additions & 8 deletions client/src/app/+videos/+video-edit/shared/video-edit.component.ts
Expand Up @@ -56,7 +56,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
@Input() videoToUpdate: VideoDetails

@Input() userVideoChannels: SelectChannelItem[] = []
@Input() schedulePublicationPossible = true
@Input() forbidScheduledPublication = true

@Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = []

Expand Down Expand Up @@ -198,13 +198,15 @@ export class VideoEditComponent implements OnInit, OnDestroy {
.subscribe(privacies => {
this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies).videoPrivacies

if (this.schedulePublicationPossible) {
this.videoPrivacies.push({
id: this.SPECIAL_SCHEDULED_PRIVACY,
label: $localize`Scheduled`,
description: $localize`Hide the video until a specific date`
})
}
// Can't schedule publication if private privacy is not available (could be deleted by a plugin)
const hasPrivatePrivacy = this.videoPrivacies.some(p => p.id === VideoPrivacy.PRIVATE)
if (this.forbidScheduledPublication || !hasPrivatePrivacy) return

this.videoPrivacies.push({
id: this.SPECIAL_SCHEDULED_PRIVACY,
label: $localize`Scheduled`,
description: $localize`Hide the video until a specific date`
})
})

this.initialVideoCaptions = this.videoCaptions.map(c => c.language.id)
Expand Down
Expand Up @@ -53,7 +53,7 @@
<form [hidden]="!isInUpdateForm" novalidate [formGroup]="form">
<my-video-edit
[form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions"
[schedulePublicationPossible]="false" [waitTranscodingEnabled]="isWaitTranscodingEnabled()"
[forbidScheduledPublication]="true" [waitTranscodingEnabled]="isWaitTranscodingEnabled()"
[validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels" [liveVideo]="liveVideo"
type="go-live"
></my-video-edit>
Expand Down
Expand Up @@ -59,7 +59,7 @@
<!-- Hidden because we want to load the component -->
<form [hidden]="!hasImportedVideo" novalidate [formGroup]="form">
<my-video-edit
[form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions" [schedulePublicationPossible]="false"
[form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions" [forbidScheduledPublication]="true"
[validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
type="import-torrent"
></my-video-edit>
Expand Down
Expand Up @@ -52,7 +52,7 @@
<!-- Hidden because we want to load the component -->
<form [hidden]="!hasImportedVideo" novalidate [formGroup]="form">
<my-video-edit
[form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions" [schedulePublicationPossible]="false"
[form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions" [forbidScheduledPublication]="true"
[validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
type="import-url"
></my-video-edit>
Expand Down
Expand Up @@ -96,7 +96,7 @@
<my-video-edit
[form]="form" [formErrors]="formErrors" [videoCaptions]="videoCaptions"
[validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
[waitTranscodingEnabled]="true" [schedulePublicationPossible]="schedulePublicationPossible"
[waitTranscodingEnabled]="true" [forbidScheduledPublication]="false"
type="upload"
></my-video-edit>

Expand Down
Expand Up @@ -47,8 +47,6 @@ 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'

Expand Down Expand Up @@ -107,8 +105,6 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy

this.resumableUploadService.events
.subscribe(state => this.onUploadVideoOngoing(state))

this.schedulePublicationPossible = this.videoPrivacies.some(p => p.id === VideoPrivacy.PRIVATE)
}

ngAfterViewInit () {
Expand Down
Expand Up @@ -7,7 +7,7 @@
<form novalidate [formGroup]="form">

<my-video-edit
[form]="form" [formErrors]="formErrors" [schedulePublicationPossible]="schedulePublicationPossible"
[form]="form" [formErrors]="formErrors" [forbidScheduledPublication]="forbidScheduledPublication"
[validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
[videoCaptions]="videoCaptions" [waitTranscodingEnabled]="isWaitTranscodingEnabled()"
type="update" (pluginFieldsAdded)="hydratePluginFieldsFromVideo()"
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/+videos/+video-edit/video-update.component.ts
Expand Up @@ -24,7 +24,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
liveVideo: LiveVideo

isUpdatingVideo = false
schedulePublicationPossible = false
forbidScheduledPublication = false
waitTranscodingEnabled = true

private updateDone = false
Expand Down Expand Up @@ -55,7 +55,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
this.videoCaptions = videoCaptions
this.liveVideo = liveVideo

this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
this.forbidScheduledPublication = this.video.privacy !== VideoPrivacy.PRIVATE
}

onFormBuilt () {
Expand Down

0 comments on commit 4afec73

Please sign in to comment.