aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/shared/video-caption/video-caption.service.ts16
1 files changed, 5 insertions, 11 deletions
diff --git a/client/src/app/shared/video-caption/video-caption.service.ts b/client/src/app/shared/video-caption/video-caption.service.ts
index a1838ab16..977f6253a 100644
--- a/client/src/app/shared/video-caption/video-caption.service.ts
+++ b/client/src/app/shared/video-caption/video-caption.service.ts
@@ -1,7 +1,7 @@
1import { catchError, map, switchMap } from 'rxjs/operators' 1import { catchError, map, switchMap } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http' 2import { HttpClient } from '@angular/common/http'
3import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
4import { forkJoin, Observable, of } from 'rxjs' 4import { Observable, of } from 'rxjs'
5import { peertubeTranslate, ResultList } from '../../../../../shared' 5import { peertubeTranslate, ResultList } from '../../../../../shared'
6import { RestExtractor } from '../rest' 6import { RestExtractor } from '../rest'
7import { VideoService } from '@app/shared/video/video.service' 7import { VideoService } from '@app/shared/video/video.service'
@@ -61,22 +61,16 @@ export class VideoCaptionService {
61 } 61 }
62 62
63 updateCaptions (videoId: number | string, videoCaptions: VideoCaptionEdit[]) { 63 updateCaptions (videoId: number | string, videoCaptions: VideoCaptionEdit[]) {
64 const observables: Observable<any>[] = [] 64 let obs = of(true)
65 65
66 for (const videoCaption of videoCaptions) { 66 for (const videoCaption of videoCaptions) {
67 if (videoCaption.action === 'CREATE') { 67 if (videoCaption.action === 'CREATE') {
68 observables.push( 68 obs = obs.pipe(switchMap(() => this.addCaption(videoId, videoCaption.language.id, videoCaption.captionfile)))
69 this.addCaption(videoId, videoCaption.language.id, videoCaption.captionfile)
70 )
71 } else if (videoCaption.action === 'REMOVE') { 69 } else if (videoCaption.action === 'REMOVE') {
72 observables.push( 70 obs = obs.pipe(switchMap(() => this.removeCaption(videoId, videoCaption.language.id)))
73 this.removeCaption(videoId, videoCaption.language.id)
74 )
75 } 71 }
76 } 72 }
77 73
78 if (observables.length === 0) return of(undefined) 74 return obs
79
80 return forkJoin(observables)
81 } 75 }
82} 76}