]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/+video-edit/video-update.resolver.ts
provide specific engine boundaries for nodejs and yarn
[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'
d0dba1fc 7import { forkJoin } from 'rxjs'
308c4275
C
8
9@Injectable()
10export class VideoUpdateResolver implements Resolve<any> {
11 constructor (
12 private videoService: VideoService,
13 private videoChannelService: VideoChannelService,
14 private videoCaptionService: VideoCaptionService
d0dba1fc
C
15 ) {
16 }
308c4275
C
17
18 resolve (route: ActivatedRouteSnapshot) {
19 const uuid: string = route.params[ 'uuid' ]
20
93cae479 21 return this.videoService.getVideo({ videoId: uuid })
d0dba1fc
C
22 .pipe(
23 switchMap(video => {
24 return forkJoin([
25 this.videoService
26 .loadCompleteDescription(video.descriptionPath)
27 .pipe(map(description => Object.assign(video, { description }))),
28
29 this.videoChannelService
30 .listAccountVideoChannels(video.account)
31 .pipe(
32 map(result => result.data),
33 map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support })))
34 ),
35
36 this.videoCaptionService
37 .listCaptions(video.id)
38 .pipe(
39 map(result => result.data)
40 )
41 ])
42 }),
43 map(([ video, videoChannels, videoCaptions ]) => ({ video, videoChannels, videoCaptions }))
44 )
308c4275
C
45 }
46}