]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - 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
index 30bcf4d74535ca0dd520d7eac3c83d26b2125cc5..3a82324c3ea5477bca546b5034aab85f6a430894 100644 (file)
@@ -1,13 +1,14 @@
-import { forkJoin } from 'rxjs'
+import { forkJoin, of } from 'rxjs'
 import { map, switchMap } from 'rxjs/operators'
 import { Injectable } from '@angular/core'
 import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
-import { VideoCaptionService, VideoChannelService, VideoService } from '@app/shared/shared-main'
+import { VideoCaptionService, VideoChannelService, VideoDetails, VideoLiveService, VideoService } from '@app/shared/shared-main'
 
 @Injectable()
 export class VideoUpdateResolver implements Resolve<any> {
   constructor (
     private videoService: VideoService,
+    private videoLiveService: VideoLiveService,
     private videoChannelService: VideoChannelService,
     private videoCaptionService: VideoCaptionService
   ) {
@@ -18,27 +19,38 @@ export class VideoUpdateResolver implements Resolve<any> {
 
     return this.videoService.getVideo({ videoId: uuid })
                .pipe(
-                 switchMap(video => {
-                   return forkJoin([
-                     this.videoService
-                         .loadCompleteDescription(video.descriptionPath)
-                         .pipe(map(description => Object.assign(video, { description }))),
+                 switchMap(video => forkJoin(this.buildVideoObservables(video))),
+                 map(([ video, videoChannels, videoCaptions, videoLive ]) => ({ video, videoChannels, videoCaptions, videoLive }))
+               )
+  }
 
-                     this.videoChannelService
-                         .listAccountVideoChannels(video.account)
-                         .pipe(
-                           map(result => result.data),
-                           map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support })))
-                         ),
+  private buildVideoObservables (video: VideoDetails) {
+    return [
+      this.videoService
+        .loadCompleteDescription(video.descriptionPath)
+        .pipe(map(description => Object.assign(video, { description }))),
 
-                     this.videoCaptionService
-                         .listCaptions(video.id)
-                         .pipe(
-                           map(result => result.data)
-                         )
-                   ])
-                 }),
-                 map(([ video, videoChannels, videoCaptions ]) => ({ video, videoChannels, videoCaptions }))
-               )
+      this.videoChannelService
+        .listAccountVideoChannels(video.account)
+        .pipe(
+          map(result => result.data),
+          map(videoChannels => videoChannels.map(c => ({
+            id: c.id,
+            label: c.displayName,
+            support: c.support,
+            avatarPath: c.avatar?.path
+          })))
+        ),
+
+      this.videoCaptionService
+        .listCaptions(video.id)
+        .pipe(
+          map(result => result.data)
+        ),
+
+      video.isLive
+          ? this.videoLiveService.getVideoLive(video.id)
+          : of(undefined)
+    ]
   }
 }