From 1942f11d5ee6926ad93dc1b79fae18325ba5de18 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Jun 2020 14:49:20 +0200 Subject: Lazy load all routes --- .../+videos/+video-edit/video-update.resolver.ts | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 client/src/app/+videos/+video-edit/video-update.resolver.ts (limited to 'client/src/app/+videos/+video-edit/video-update.resolver.ts') diff --git a/client/src/app/+videos/+video-edit/video-update.resolver.ts b/client/src/app/+videos/+video-edit/video-update.resolver.ts new file mode 100644 index 000000000..30bcf4d74 --- /dev/null +++ b/client/src/app/+videos/+video-edit/video-update.resolver.ts @@ -0,0 +1,44 @@ +import { forkJoin } 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' + +@Injectable() +export class VideoUpdateResolver implements Resolve { + constructor ( + private videoService: VideoService, + private videoChannelService: VideoChannelService, + private videoCaptionService: VideoCaptionService + ) { + } + + resolve (route: ActivatedRouteSnapshot) { + 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 }))), + + this.videoChannelService + .listAccountVideoChannels(video.account) + .pipe( + map(result => result.data), + map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support }))) + ), + + this.videoCaptionService + .listCaptions(video.id) + .pipe( + map(result => result.data) + ) + ]) + }), + map(([ video, videoChannels, videoCaptions ]) => ({ video, videoChannels, videoCaptions })) + ) + } +} -- cgit v1.2.3