1 import { Injectable } from '@angular/core'
2 import { VideoService } from '@app/shared/video/video.service'
3 import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
4 import { map, switchMap } from 'rxjs/operators'
5 import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
6 import { VideoCaptionService } from '@app/shared/video-caption'
7 import { forkJoin } from 'rxjs'
10 export class VideoUpdateResolver implements Resolve<any> {
12 private videoService: VideoService,
13 private videoChannelService: VideoChannelService,
14 private videoCaptionService: VideoCaptionService
18 resolve (route: ActivatedRouteSnapshot) {
19 const uuid: string = route.params[ 'uuid' ]
21 return this.videoService.getVideo(uuid)
26 .loadCompleteDescription(video.descriptionPath)
27 .pipe(map(description => Object.assign(video, { description }))),
29 this.videoChannelService
30 .listAccountVideoChannels(video.account)
32 map(result => result.data),
33 map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support })))
36 this.videoCaptionService
37 .listCaptions(video.id)
39 map(result => result.data)
43 map(([ video, videoChannels, videoCaptions ]) => ({ video, videoChannels, videoCaptions }))