aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-01 08:51:26 +0200
committerChocobozzz <me@florianbigard.com>2018-10-01 08:54:58 +0200
commited4c3c091009f85dd5e2775087b33ebd7f22ffd2 (patch)
tree1d182d04f3e48f1aff7d647a7b026f1d77d21fe6 /client/src
parent6360e12616d54c2321ee5e3a6523a8b60d70c0a7 (diff)
downloadPeerTube-ed4c3c091009f85dd5e2775087b33ebd7f22ffd2.tar.gz
PeerTube-ed4c3c091009f85dd5e2775087b33ebd7f22ffd2.tar.zst
PeerTube-ed4c3c091009f85dd5e2775087b33ebd7f22ffd2.zip
Update captions in sequence to avoid concurrence issues
Diffstat (limited to 'client/src')
-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}