aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-edit/video-update.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-16 18:09:31 +0200
committerChocobozzz <me@florianbigard.com>2018-07-16 18:09:31 +0200
commit308c427551c3e20cd9172be58636d8c178f5ae70 (patch)
tree10c96e81ccf8da8f7460fc76f90963e3a7f6ac9c /client/src/app/videos/+video-edit/video-update.component.ts
parentef4c78da4f0da61aebfa42f6e8420bf431a68bc8 (diff)
downloadPeerTube-308c427551c3e20cd9172be58636d8c178f5ae70.tar.gz
PeerTube-308c427551c3e20cd9172be58636d8c178f5ae70.tar.zst
PeerTube-308c427551c3e20cd9172be58636d8c178f5ae70.zip
Use a resolver when updating the video
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.ts70
1 files changed, 23 insertions, 47 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 4fe65bccd..774772e14 100644
--- a/client/src/app/videos/+video-edit/video-update.component.ts
+++ b/client/src/app/videos/+video-edit/video-update.component.ts
@@ -49,55 +49,31 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
49 this.buildForm({}) 49 this.buildForm({})
50 50
51 this.serverService.videoPrivaciesLoaded 51 this.serverService.videoPrivaciesLoaded
52 .subscribe(() => this.videoPrivacies = this.serverService.getVideoPrivacies()) 52 .subscribe(() => this.videoPrivacies = this.serverService.getVideoPrivacies())
53
54 this.route.data
55 .pipe(map(data => data.videoData))
56 .subscribe(({ video, videoChannels, videoCaptions }) => {
57 this.video = new VideoEdit(video)
58 this.userVideoChannels = videoChannels
59 this.videoCaptions = videoCaptions
60
61 // We cannot set private a video that was not private
62 if (this.video.privacy !== VideoPrivacy.PRIVATE) {
63 this.videoPrivacies = this.videoPrivacies.filter(p => p.id.toString() !== VideoPrivacy.PRIVATE.toString())
64 } else { // We can schedule video publication only if it it is private
65 this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
66 }
53 67
54 const uuid: string = this.route.snapshot.params[ 'uuid' ] 68 // FIXME: Angular does not detec
55 this.videoService.getVideo(uuid) 69 setTimeout(() => this.hydrateFormFromVideo())
56 .pipe( 70 },
57 switchMap(video => {
58 return this.videoService
59 .loadCompleteDescription(video.descriptionPath)
60 .pipe(map(description => Object.assign(video, { description })))
61 }),
62 switchMap(video => {
63 return this.videoChannelService
64 .listAccountVideoChannels(video.account)
65 .pipe(
66 map(result => result.data),
67 map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support }))),
68 map(videoChannels => ({ video, videoChannels }))
69 )
70 }),
71 switchMap(({ video, videoChannels }) => {
72 return this.videoCaptionService
73 .listCaptions(video.id)
74 .pipe(
75 map(result => result.data),
76 map(videoCaptions => ({ video, videoChannels, videoCaptions }))
77 )
78 })
79 )
80 .subscribe(
81 ({ video, videoChannels, videoCaptions }) => {
82 this.video = new VideoEdit(video)
83 this.userVideoChannels = videoChannels
84 this.videoCaptions = videoCaptions
85
86 // We cannot set private a video that was not private
87 if (this.video.privacy !== VideoPrivacy.PRIVATE) {
88 this.videoPrivacies = this.videoPrivacies.filter(p => p.id.toString() !== VideoPrivacy.PRIVATE.toString())
89 } else { // We can schedule video publication only if it it is private
90 this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
91 }
92
93 this.hydrateFormFromVideo()
94 },
95 71
96 err => { 72 err => {
97 console.error(err) 73 console.error(err)
98 this.notificationsService.error(this.i18n('Error'), err.message) 74 this.notificationsService.error(this.i18n('Error'), err.message)
99 } 75 }
100 ) 76 )
101 } 77 }
102 78
103 checkForm () { 79 checkForm () {