X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bvideos%2F%2Bvideo-edit%2Fvideo-update.resolver.ts;h=82dae5c1cef83d36ae3d51613855579aef2afe05;hb=7b51ede977c299a74728171d8c124bcc4cbba6ea;hp=30bcf4d74535ca0dd520d7eac3c83d26b2125cc5;hpb=1942f11d5ee6926ad93dc1b79fae18325ba5de18;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+videos/+video-edit/video-update.resolver.ts b/client/src/app/+videos/+video-edit/video-update.resolver.ts index 30bcf4d74..82dae5c1c 100644 --- a/client/src/app/+videos/+video-edit/video-update.resolver.ts +++ b/client/src/app/+videos/+video-edit/video-update.resolver.ts @@ -1,44 +1,49 @@ -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 { 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 { constructor ( private videoService: VideoService, - 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 => { - return forkJoin([ - this.videoService - .loadCompleteDescription(video.descriptionPath) - .pipe(map(description => Object.assign(video, { description }))), + switchMap(video => forkJoin(this.buildVideoObservables(video))), + map(([ video, videoChannels, videoCaptions, liveVideo ]) => ({ video, videoChannels, videoCaptions, liveVideo })) + ) + } - 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 })) - ) + listUserChannelsForSelect(this.authService), + + this.videoCaptionService + .listCaptions(video.id) + .pipe( + map(result => result.data) + ), + + video.isLive + ? this.liveVideoService.getVideoLive(video.id) + : of(undefined) + ] } }