diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-23 14:49:20 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-23 16:00:49 +0200 |
commit | 1942f11d5ee6926ad93dc1b79fae18325ba5de18 (patch) | |
tree | 3f2a3cd9466a56c419d197ac832a3e9cbc86bec4 /client/src/app/+videos/+video-edit/video-update.resolver.ts | |
parent | 67ed6552b831df66713bac9e672738796128d33f (diff) | |
download | PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.tar.gz PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.tar.zst PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.zip |
Lazy load all routes
Diffstat (limited to 'client/src/app/+videos/+video-edit/video-update.resolver.ts')
-rw-r--r-- | client/src/app/+videos/+video-edit/video-update.resolver.ts | 44 |
1 files changed, 44 insertions, 0 deletions
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 @@ | |||
1 | import { forkJoin } from 'rxjs' | ||
2 | import { map, switchMap } from 'rxjs/operators' | ||
3 | import { Injectable } from '@angular/core' | ||
4 | import { ActivatedRouteSnapshot, Resolve } from '@angular/router' | ||
5 | import { VideoCaptionService, VideoChannelService, VideoService } from '@app/shared/shared-main' | ||
6 | |||
7 | @Injectable() | ||
8 | export class VideoUpdateResolver implements Resolve<any> { | ||
9 | constructor ( | ||
10 | private videoService: VideoService, | ||
11 | private videoChannelService: VideoChannelService, | ||
12 | private videoCaptionService: VideoCaptionService | ||
13 | ) { | ||
14 | } | ||
15 | |||
16 | resolve (route: ActivatedRouteSnapshot) { | ||
17 | const uuid: string = route.params[ 'uuid' ] | ||
18 | |||
19 | return this.videoService.getVideo({ videoId: uuid }) | ||
20 | .pipe( | ||
21 | switchMap(video => { | ||
22 | return forkJoin([ | ||
23 | this.videoService | ||
24 | .loadCompleteDescription(video.descriptionPath) | ||
25 | .pipe(map(description => Object.assign(video, { description }))), | ||
26 | |||
27 | this.videoChannelService | ||
28 | .listAccountVideoChannels(video.account) | ||
29 | .pipe( | ||
30 | map(result => result.data), | ||
31 | map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support }))) | ||
32 | ), | ||
33 | |||
34 | this.videoCaptionService | ||
35 | .listCaptions(video.id) | ||
36 | .pipe( | ||
37 | map(result => result.data) | ||
38 | ) | ||
39 | ]) | ||
40 | }), | ||
41 | map(([ video, videoChannels, videoCaptions ]) => ({ video, videoChannels, videoCaptions })) | ||
42 | ) | ||
43 | } | ||
44 | } | ||