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()
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)))
}
}
updateCaptions (videoId: number | string, videoCaptions: VideoCaptionEdit[]) {
- if (videoCaptions.length === 0) return of(true)
-
const observables: Observable<any>[] = []
for (const videoCaption of videoCaptions) {
}
}
+ if (observables.length === 0) return of(true)
+
return forkJoin(observables)
}
}