X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fvideo-caption%2Fvideo-caption.service.ts;h=0ff094d1fe0cc61ff960d0d4d42eb0243498a533;hb=ad77475251c3516dd5851a08655be79d7bf76245;hp=d1444902d1dd6e5dfe1a3c0d4149fbb62f38212b;hpb=329d9086601b7ae2127be12166ee8c892c289c6e;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 d1444902d..0ff094d1f 100644 --- a/client/src/app/shared/video-caption/video-caption.service.ts +++ b/client/src/app/shared/video-caption/video-caption.service.ts @@ -6,7 +6,7 @@ import { ResultList } from '../../../../../shared' import { RestExtractor, RestService } from '../rest' import { VideoCaption } from '../../../../../shared/models/videos/video-caption.model' import { VideoService } from '@app/shared/video/video.service' -import { objectToFormData } from '@app/shared/misc/utils' +import { objectToFormData, sortBy } from '@app/shared/misc/utils' import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model' @Injectable() @@ -19,6 +19,11 @@ export class VideoCaptionService { listCaptions (videoId: number | string): Observable> { return this.authHttp.get>(VideoService.BASE_VIDEO_URL + videoId + '/captions') + .pipe(map(res => { + sortBy(res.data, 'language', 'label') + + return res + })) .pipe(catchError(res => this.restExtractor.handleError(res))) } @@ -42,8 +47,6 @@ export class VideoCaptionService { } updateCaptions (videoId: number | string, videoCaptions: VideoCaptionEdit[]) { - if (videoCaptions.length === 0) return of(true) - const observables: Observable[] = [] for (const videoCaption of videoCaptions) { @@ -58,6 +61,8 @@ export class VideoCaptionService { } } + if (observables.length === 0) return of(true) + return forkJoin(observables) } }