video: VideoEdit
isUpdatingVideo = false
- videoPrivacies: VideoConstant<string>[] = []
+ videoPrivacies: VideoConstant<VideoPrivacy>[] = []
userVideoChannels: { id: number, label: string, support: string }[] = []
schedulePublicationPossible = false
videoCaptions: VideoCaptionEdit[] = []
+ private updateDone = false
+
constructor (
protected formValidatorService: FormValidatorService,
private route: ActivatedRoute,
// We cannot set private a video that was not private
if (this.video.privacy !== VideoPrivacy.PRIVATE) {
- this.videoPrivacies = this.videoPrivacies.filter(p => p.id.toString() !== VideoPrivacy.PRIVATE.toString())
+ this.videoPrivacies = this.videoPrivacies.filter(p => p.id !== VideoPrivacy.PRIVATE)
} else { // We can schedule video publication only if it it is private
this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
}
- // FIXME: Angular does not detec
+ this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
+
+ // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
setTimeout(() => this.hydrateFormFromVideo())
},
)
}
+ canDeactivate () {
+ if (this.updateDone === true) return { canDeactivate: true }
+
+ for (const caption of this.videoCaptions) {
+ if (caption.action) return { canDeactivate: false }
+ }
+
+ return { canDeactivate: this.formChanged === false }
+ }
+
checkForm () {
this.forceCheck()
)
.subscribe(
() => {
+ this.updateDone = true
this.isUpdatingVideo = false
this.loadingBar.complete()
this.notificationsService.success(this.i18n('Success'), this.i18n('Video updated.'))
console.error(err)
}
)
-
}
private hydrateFormFromVideo () {