]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+videos/+video-edit/video-update.resolver.ts
Update angular
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-edit / video-update.resolver.ts
index 3a82324c3ea5477bca546b5034aab85f6a430894..6612d22dee7254a6e8f23e4a203d2ce3a45efbc0 100644 (file)
@@ -1,26 +1,30 @@
 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, VideoDetails, VideoLiveService, VideoService } from '@app/shared/shared-main'
+import { ActivatedRouteSnapshot } from '@angular/router'
+import { AuthService } from '@app/core'
+import { listUserChannelsForSelect } from '@app/helpers'
+import { VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main'
+import { LiveVideoService } from '@app/shared/shared-video-live'
 
 @Injectable()
-export class VideoUpdateResolver implements Resolve<any> {
+export class VideoUpdateResolver {
   constructor (
     private videoService: VideoService,
-    private videoLiveService: VideoLiveService,
-    private videoChannelService: VideoChannelService,
+    private liveVideoService: LiveVideoService,
+    private authService: AuthService,
     private videoCaptionService: VideoCaptionService
   ) {
   }
 
   resolve (route: ActivatedRouteSnapshot) {
-    const uuid: string = route.params[ 'uuid' ]
+    const uuid: string = route.params['uuid']
 
     return this.videoService.getVideo({ videoId: uuid })
                .pipe(
                  switchMap(video => forkJoin(this.buildVideoObservables(video))),
-                 map(([ video, videoChannels, videoCaptions, videoLive ]) => ({ video, videoChannels, videoCaptions, videoLive }))
+                 map(([ video, videoSource, videoChannels, videoCaptions, liveVideo ]) =>
+                   ({ video, videoChannels, videoCaptions, videoSource, liveVideo }))
                )
   }
 
@@ -30,27 +34,19 @@ export class VideoUpdateResolver implements Resolve<any> {
         .loadCompleteDescription(video.descriptionPath)
         .pipe(map(description => Object.assign(video, { description }))),
 
-      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.videoService.getSource(video.id),
+
+      listUserChannelsForSelect(this.authService),
 
       this.videoCaptionService
-        .listCaptions(video.id)
+        .listCaptions(video.uuid)
         .pipe(
           map(result => result.data)
         ),
 
       video.isLive
-          ? this.videoLiveService.getVideoLive(video.id)
-          : of(undefined)
+        ? this.liveVideoService.getVideoLive(video.id)
+        : of(undefined)
     ]
   }
 }