- this.buildForm()
-
- this.videoCategories = this.videoService.videoCategories
- this.videoLicences = this.videoService.videoLicences
- this.videoLanguages = this.videoService.videoLanguages
-
- const uuid: string = this.route.snapshot.params['uuid']
- this.videoService.getVideo(uuid)
- .subscribe(
- video => {
- this.video = video
-
- this.hydrateFormFromVideo()
- },
-
- err => {
- console.error(err)
- this.error = 'Cannot fetch video.'
- }
- )
+ this.buildForm({})
+
+ this.serverService.videoPrivaciesLoaded
+ .subscribe(() => this.videoPrivacies = this.serverService.getVideoPrivacies())
+
+ this.route.data
+ .pipe(map(data => data.videoData))
+ .subscribe(({ video, videoChannels, videoCaptions }) => {
+ this.video = new VideoEdit(video)
+ this.userVideoChannels = videoChannels
+ this.videoCaptions = videoCaptions
+
+ // 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())
+ } else { // We can schedule video publication only if it it is private
+ this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
+ }
+
+ // FIXME: Angular does not detec
+ setTimeout(() => this.hydrateFormFromVideo())
+ },
+
+ err => {
+ console.error(err)
+ this.notificationsService.error(this.i18n('Error'), err.message)
+ }
+ )