]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+videos/+video-edit/video-update.resolver.ts
Restore line feed for markdown lists support in comments
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-edit / video-update.resolver.ts
CommitLineData
67ed6552
C
1import { forkJoin } from 'rxjs'
2import { map, switchMap } from 'rxjs/operators'
308c4275 3import { Injectable } from '@angular/core'
308c4275 4import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
67ed6552 5import { VideoCaptionService, VideoChannelService, VideoService } from '@app/shared/shared-main'
308c4275
C
6
7@Injectable()
8export class VideoUpdateResolver implements Resolve<any> {
9 constructor (
10 private videoService: VideoService,
11 private videoChannelService: VideoChannelService,
12 private videoCaptionService: VideoCaptionService
d0dba1fc
C
13 ) {
14 }
308c4275
C
15
16 resolve (route: ActivatedRouteSnapshot) {
17 const uuid: string = route.params[ 'uuid' ]
18
93cae479 19 return this.videoService.getVideo({ videoId: uuid })
d0dba1fc
C
20 .pipe(
21 switchMap(video => {
22 return forkJoin([
23 this.videoService
24 .loadCompleteDescription(video.descriptionPath)
25 .pipe(map(description => Object.assign(video, { description }))),
26
27 this.videoChannelService
28 .listAccountVideoChannels(video.account)
29 .pipe(
30 map(result => result.data),
02c01341
RK
31 map(videoChannels => videoChannels.map(c => ({
32 id: c.id,
33 label: c.displayName,
34 support: c.support,
35 avatarPath: c.avatar?.path
36 })))
d0dba1fc
C
37 ),
38
39 this.videoCaptionService
40 .listCaptions(video.id)
41 .pipe(
42 map(result => result.data)
43 )
44 ])
45 }),
46 map(([ video, videoChannels, videoCaptions ]) => ({ video, videoChannels, videoCaptions }))
47 )
308c4275
C
48 }
49}