]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/+video-edit/video-update.resolver.ts
Update client according to new model paths
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-edit / video-update.resolver.ts
CommitLineData
308c4275
C
1import { Injectable } from '@angular/core'
2import { VideoService } from '@app/shared/video/video.service'
3import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
4import { map, switchMap } from 'rxjs/operators'
5import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
6import { VideoCaptionService } from '@app/shared/video-caption'
7
8@Injectable()
9export class VideoUpdateResolver implements Resolve<any> {
10 constructor (
11 private videoService: VideoService,
12 private videoChannelService: VideoChannelService,
13 private videoCaptionService: VideoCaptionService
14 ) {}
15
16 resolve (route: ActivatedRouteSnapshot) {
17 const uuid: string = route.params[ 'uuid' ]
18
19 return this.videoService.getVideo(uuid)
20 .pipe(
21 switchMap(video => {
22 return this.videoService
23 .loadCompleteDescription(video.descriptionPath)
24 .pipe(map(description => Object.assign(video, { description })))
25 }),
26 switchMap(video => {
27 return this.videoChannelService
28 .listAccountVideoChannels(video.account)
29 .pipe(
30 map(result => result.data),
31 map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support }))),
32 map(videoChannels => ({ video, videoChannels }))
33 )
34 }),
35 switchMap(({ video, videoChannels }) => {
36 return this.videoCaptionService
37 .listCaptions(video.id)
38 .pipe(
39 map(result => result.data),
40 map(videoCaptions => ({ video, videoChannels, videoCaptions }))
41 )
42 })
43 )
44 }
45}