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