X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fvideo-caption%2Fvideo-caption.service.ts;h=977f6253ab4e4f4ff78a4456ca41bf408ead5cef;hb=5dfb7c1dec8222b0bbccac5b56ad46da1438747e;hp=a1838ab16219a0311afcac253ffeee6d3977bee6;hpb=0b4e5fe32708afce54212810738aa4d0c3dc178d;p=github%2FChocobozzz%2FPeerTube.git 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 @@ import { catchError, map, switchMap } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { Injectable } from '@angular/core' -import { forkJoin, Observable, of } from 'rxjs' +import { Observable, of } from 'rxjs' import { peertubeTranslate, ResultList } from '../../../../../shared' import { RestExtractor } from '../rest' import { VideoService } from '@app/shared/video/video.service' @@ -61,22 +61,16 @@ export class VideoCaptionService { } updateCaptions (videoId: number | string, videoCaptions: VideoCaptionEdit[]) { - const observables: Observable[] = [] + let obs = of(true) for (const videoCaption of videoCaptions) { if (videoCaption.action === 'CREATE') { - observables.push( - this.addCaption(videoId, videoCaption.language.id, videoCaption.captionfile) - ) + obs = obs.pipe(switchMap(() => this.addCaption(videoId, videoCaption.language.id, videoCaption.captionfile))) } else if (videoCaption.action === 'REMOVE') { - observables.push( - this.removeCaption(videoId, videoCaption.language.id) - ) + obs = obs.pipe(switchMap(() => this.removeCaption(videoId, videoCaption.language.id))) } } - if (observables.length === 0) return of(undefined) - - return forkJoin(observables) + return obs } }