aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-edit/video-update.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-22 15:51:02 +0200
committerChocobozzz <me@florianbigard.com>2021-10-22 15:51:02 +0200
commit0ba9696c012804670ccdd5256acdaa7ed9484339 (patch)
tree50a1f5e47221c6c200260ab6af164e676a466de1 /client/src/app/+videos/+video-edit/video-update.component.ts
parent382258676c3ab83f9cebfc4e378ab955cd8fd9ff (diff)
downloadPeerTube-0ba9696c012804670ccdd5256acdaa7ed9484339.tar.gz
PeerTube-0ba9696c012804670ccdd5256acdaa7ed9484339.tar.zst
PeerTube-0ba9696c012804670ccdd5256acdaa7ed9484339.zip
Cleanup video update component
Diffstat (limited to 'client/src/app/+videos/+video-edit/video-update.component.ts')
-rw-r--r--client/src/app/+videos/+video-edit/video-update.component.ts53
1 files changed, 22 insertions, 31 deletions
diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts
index 9bef60133..e44aea10a 100644
--- a/client/src/app/+videos/+video-edit/video-update.component.ts
+++ b/client/src/app/+videos/+video-edit/video-update.component.ts
@@ -1,5 +1,5 @@
1import { of } from 'rxjs' 1import { of } from 'rxjs'
2import { map, switchMap } from 'rxjs/operators' 2import { switchMap } from 'rxjs/operators'
3import { SelectChannelItem } from 'src/types/select-options-item.model' 3import { SelectChannelItem } from 'src/types/select-options-item.model'
4import { Component, HostListener, OnInit } from '@angular/core' 4import { Component, HostListener, OnInit } from '@angular/core'
5import { ActivatedRoute, Router } from '@angular/router' 5import { ActivatedRoute, Router } from '@angular/router'
@@ -45,37 +45,28 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
45 ngOnInit () { 45 ngOnInit () {
46 this.buildForm({}) 46 this.buildForm({})
47 47
48 this.route.data 48 const { videoData } = this.route.snapshot.data
49 .pipe(map(data => data.videoData)) 49 const { video, videoChannels, videoCaptions, liveVideo } = videoData
50 .subscribe({
51 next: ({ video, videoChannels, videoCaptions, liveVideo }) => {
52 this.video = new VideoEdit(video)
53 this.videoDetails = video
54
55 this.userVideoChannels = videoChannels
56 this.videoCaptions = videoCaptions
57 this.liveVideo = liveVideo
58
59 this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
60
61 // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
62 setTimeout(() => {
63 hydrateFormFromVideo(this.form, this.video, true)
64
65 if (this.liveVideo) {
66 this.form.patchValue({
67 saveReplay: this.liveVideo.saveReplay,
68 permanentLive: this.liveVideo.permanentLive
69 })
70 }
71 })
72 },
73 50
74 error: err => { 51 this.video = new VideoEdit(video)
75 console.error(err) 52 this.videoDetails = video
76 this.notifier.error(err.message) 53
77 } 54 this.userVideoChannels = videoChannels
78 }) 55 this.videoCaptions = videoCaptions
56 this.liveVideo = liveVideo
57
58 this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
59 }
60
61 onFormBuilt () {
62 hydrateFormFromVideo(this.form, this.video, true)
63
64 if (this.liveVideo) {
65 this.form.patchValue({
66 saveReplay: this.liveVideo.saveReplay,
67 permanentLive: this.liveVideo.permanentLive
68 })
69 }
79 } 70 }
80 71
81 @HostListener('window:beforeunload', [ '$event' ]) 72 @HostListener('window:beforeunload', [ '$event' ])