aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-edit/video-add.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/videos/+video-edit/video-add.component.ts')
-rw-r--r--client/src/app/videos/+video-edit/video-add.component.ts50
1 files changed, 27 insertions, 23 deletions
diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts
index 7c4b6260b..8c30cedfb 100644
--- a/client/src/app/videos/+video-edit/video-add.component.ts
+++ b/client/src/app/videos/+video-edit/video-add.component.ts
@@ -15,6 +15,8 @@ import { VideoEdit } from '../../shared/video/video-edit.model'
15import { VideoService } from '../../shared/video/video.service' 15import { VideoService } from '../../shared/video/video.service'
16import { I18n } from '@ngx-translate/i18n-polyfill' 16import { I18n } from '@ngx-translate/i18n-polyfill'
17import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 17import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
18import { switchMap } from 'rxjs/operators'
19import { VideoCaptionService } from '@app/shared/video-caption'
18 20
19@Component({ 21@Component({
20 selector: 'my-videos-add', 22 selector: 'my-videos-add',
@@ -46,6 +48,7 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy
46 videoPrivacies = [] 48 videoPrivacies = []
47 firstStepPrivacyId = 0 49 firstStepPrivacyId = 0
48 firstStepChannelId = 0 50 firstStepChannelId = 0
51 videoCaptions = []
49 52
50 constructor ( 53 constructor (
51 protected formValidatorService: FormValidatorService, 54 protected formValidatorService: FormValidatorService,
@@ -56,7 +59,8 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy
56 private serverService: ServerService, 59 private serverService: ServerService,
57 private videoService: VideoService, 60 private videoService: VideoService,
58 private loadingBar: LoadingBarService, 61 private loadingBar: LoadingBarService,
59 private i18n: I18n 62 private i18n: I18n,
63 private videoCaptionService: VideoCaptionService
60 ) { 64 ) {
61 super() 65 super()
62 } 66 }
@@ -159,11 +163,8 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy
159 let name: string 163 let name: string
160 164
161 // If the name of the file is very small, keep the extension 165 // If the name of the file is very small, keep the extension
162 if (nameWithoutExtension.length < 3) { 166 if (nameWithoutExtension.length < 3) name = videofile.name
163 name = videofile.name 167 else name = nameWithoutExtension
164 } else {
165 name = nameWithoutExtension
166 }
167 168
168 const privacy = this.firstStepPrivacyId.toString() 169 const privacy = this.firstStepPrivacyId.toString()
169 const nsfw = false 170 const nsfw = false
@@ -225,22 +226,25 @@ export class VideoAddComponent extends FormReactive implements OnInit, OnDestroy
225 this.isUpdatingVideo = true 226 this.isUpdatingVideo = true
226 this.loadingBar.start() 227 this.loadingBar.start()
227 this.videoService.updateVideo(video) 228 this.videoService.updateVideo(video)
228 .subscribe( 229 .pipe(
229 () => { 230 // Then update captions
230 this.isUpdatingVideo = false 231 switchMap(() => this.videoCaptionService.updateCaptions(video.id, this.videoCaptions))
231 this.isUploadingVideo = false 232 )
232 this.loadingBar.complete() 233 .subscribe(
233 234 () => {
234 this.notificationsService.success(this.i18n('Success'), this.i18n('Video published.')) 235 this.isUpdatingVideo = false
235 this.router.navigate([ '/videos/watch', video.uuid ]) 236 this.isUploadingVideo = false
236 }, 237 this.loadingBar.complete()
237 238
238 err => { 239 this.notificationsService.success(this.i18n('Success'), this.i18n('Video published.'))
239 this.isUpdatingVideo = false 240 this.router.navigate([ '/videos/watch', video.uuid ])
240 this.notificationsService.error(this.i18n('Error'), err.message) 241 },
241 console.error(err) 242
242 } 243 err => {
243 ) 244 this.isUpdatingVideo = false
244 245 this.notificationsService.error(this.i18n('Error'), err.message)
246 console.error(err)
247 }
248 )
245 } 249 }
246} 250}