diff options
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.ts | 48 |
1 files changed, 33 insertions, 15 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 c4e6f44de..b67874401 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts | |||
@@ -12,6 +12,7 @@ import { VideoService } from '../../shared/video/video.service' | |||
12 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | 12 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' |
13 | import { I18n } from '@ngx-translate/i18n-polyfill' | 13 | import { I18n } from '@ngx-translate/i18n-polyfill' |
14 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | 14 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' |
15 | import { VideoCaptionService } from '@app/shared/video-caption' | ||
15 | 16 | ||
16 | @Component({ | 17 | @Component({ |
17 | selector: 'my-videos-update', | 18 | selector: 'my-videos-update', |
@@ -25,6 +26,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
25 | videoPrivacies = [] | 26 | videoPrivacies = [] |
26 | userVideoChannels = [] | 27 | userVideoChannels = [] |
27 | schedulePublicationPossible = false | 28 | schedulePublicationPossible = false |
29 | videoCaptions = [] | ||
28 | 30 | ||
29 | constructor ( | 31 | constructor ( |
30 | protected formValidatorService: FormValidatorService, | 32 | protected formValidatorService: FormValidatorService, |
@@ -36,6 +38,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
36 | private authService: AuthService, | 38 | private authService: AuthService, |
37 | private loadingBar: LoadingBarService, | 39 | private loadingBar: LoadingBarService, |
38 | private videoChannelService: VideoChannelService, | 40 | private videoChannelService: VideoChannelService, |
41 | private videoCaptionService: VideoCaptionService, | ||
39 | private i18n: I18n | 42 | private i18n: I18n |
40 | ) { | 43 | ) { |
41 | super() | 44 | super() |
@@ -63,12 +66,21 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
63 | map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support }))), | 66 | map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support }))), |
64 | map(videoChannels => ({ video, videoChannels })) | 67 | map(videoChannels => ({ video, videoChannels })) |
65 | ) | 68 | ) |
69 | }), | ||
70 | switchMap(({ video, videoChannels }) => { | ||
71 | return this.videoCaptionService | ||
72 | .listCaptions(video.id) | ||
73 | .pipe( | ||
74 | map(result => result.data), | ||
75 | map(videoCaptions => ({ video, videoChannels, videoCaptions })) | ||
76 | ) | ||
66 | }) | 77 | }) |
67 | ) | 78 | ) |
68 | .subscribe( | 79 | .subscribe( |
69 | ({ video, videoChannels }) => { | 80 | ({ video, videoChannels, videoCaptions }) => { |
70 | this.video = new VideoEdit(video) | 81 | this.video = new VideoEdit(video) |
71 | this.userVideoChannels = videoChannels | 82 | this.userVideoChannels = videoChannels |
83 | this.videoCaptions = videoCaptions | ||
72 | 84 | ||
73 | // We cannot set private a video that was not private | 85 | // We cannot set private a video that was not private |
74 | if (this.video.privacy !== VideoPrivacy.PRIVATE) { | 86 | if (this.video.privacy !== VideoPrivacy.PRIVATE) { |
@@ -102,21 +114,27 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
102 | 114 | ||
103 | this.loadingBar.start() | 115 | this.loadingBar.start() |
104 | this.isUpdatingVideo = true | 116 | this.isUpdatingVideo = true |
117 | |||
118 | // Update the video | ||
105 | this.videoService.updateVideo(this.video) | 119 | this.videoService.updateVideo(this.video) |
106 | .subscribe( | 120 | .pipe( |
107 | () => { | 121 | // Then update captions |
108 | this.isUpdatingVideo = false | 122 | switchMap(() => this.videoCaptionService.updateCaptions(this.video.id, this.videoCaptions)) |
109 | this.loadingBar.complete() | 123 | ) |
110 | this.notificationsService.success(this.i18n('Success'), this.i18n('Video updated.')) | 124 | .subscribe( |
111 | this.router.navigate([ '/videos/watch', this.video.uuid ]) | 125 | () => { |
112 | }, | 126 | this.isUpdatingVideo = false |
113 | 127 | this.loadingBar.complete() | |
114 | err => { | 128 | this.notificationsService.success(this.i18n('Success'), this.i18n('Video updated.')) |
115 | this.isUpdatingVideo = false | 129 | this.router.navigate([ '/videos/watch', this.video.uuid ]) |
116 | this.notificationsService.error(this.i18n('Error'), err.message) | 130 | }, |
117 | console.error(err) | 131 | |
118 | } | 132 | err => { |
119 | ) | 133 | this.isUpdatingVideo = false |
134 | this.notificationsService.error(this.i18n('Error'), err.message) | ||
135 | console.error(err) | ||
136 | } | ||
137 | ) | ||
120 | 138 | ||
121 | } | 139 | } |
122 | 140 | ||