]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/video-caption/video-caption.service.ts
Sort video captions
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / video-caption / video-caption.service.ts
index 4ae8ebd0a5c89b9e51feba24997715ca65d8eafd..0ff094d1fe0cc61ff960d0d4d42eb0243498a533 100644 (file)
@@ -1,12 +1,12 @@
 import { catchError, map } from 'rxjs/operators'
 import { HttpClient } from '@angular/common/http'
 import { Injectable } from '@angular/core'
-import { forkJoin, Observable } from 'rxjs'
+import { forkJoin, Observable, of } from 'rxjs'
 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<ResultList<VideoCaption>> {
     return this.authHttp.get<ResultList<VideoCaption>>(VideoService.BASE_VIDEO_URL + videoId + '/captions')
+               .pipe(map(res => {
+                 sortBy(res.data, 'language', 'label')
+
+                 return res
+               }))
                .pipe(catchError(res => this.restExtractor.handleError(res)))
   }
 
@@ -56,6 +61,8 @@ export class VideoCaptionService {
       }
     }
 
+    if (observables.length === 0) return of(true)
+
     return forkJoin(observables)
   }
 }