aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-25 10:51:52 +0200
committerChocobozzz <me@florianbigard.com>2019-04-25 10:52:11 +0200
commitd0dba1fce6dcc0b91c0561eda8707c5c5bb6e626 (patch)
tree4df9aa492fa6238d0b6a8eed21aa15b3c392ecc0 /client/src
parentf3ae606caf74c8a173ce44bf3f913f1488f97d7f (diff)
downloadPeerTube-d0dba1fce6dcc0b91c0561eda8707c5c5bb6e626.tar.gz
PeerTube-d0dba1fce6dcc0b91c0561eda8707c5c5bb6e626.tar.zst
PeerTube-d0dba1fce6dcc0b91c0561eda8707c5c5bb6e626.zip
Optimize video update page load
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/videos/+video-edit/video-update.resolver.ts51
1 files changed, 26 insertions, 25 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
index 269fe3684..384458127 100644
--- a/client/src/app/videos/+video-edit/video-update.resolver.ts
+++ b/client/src/app/videos/+video-edit/video-update.resolver.ts
@@ -4,6 +4,7 @@ import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
4import { map, switchMap } from 'rxjs/operators' 4import { map, switchMap } from 'rxjs/operators'
5import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 5import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
6import { VideoCaptionService } from '@app/shared/video-caption' 6import { VideoCaptionService } from '@app/shared/video-caption'
7import { forkJoin } from 'rxjs'
7 8
8@Injectable() 9@Injectable()
9export class VideoUpdateResolver implements Resolve<any> { 10export class VideoUpdateResolver implements Resolve<any> {
@@ -11,35 +12,35 @@ export class VideoUpdateResolver implements Resolve<any> {
11 private videoService: VideoService, 12 private videoService: VideoService,
12 private videoChannelService: VideoChannelService, 13 private videoChannelService: VideoChannelService,
13 private videoCaptionService: VideoCaptionService 14 private videoCaptionService: VideoCaptionService
14 ) {} 15 ) {
16 }
15 17
16 resolve (route: ActivatedRouteSnapshot) { 18 resolve (route: ActivatedRouteSnapshot) {
17 const uuid: string = route.params[ 'uuid' ] 19 const uuid: string = route.params[ 'uuid' ]
18 20
19 return this.videoService.getVideo(uuid) 21 return this.videoService.getVideo(uuid)
20 .pipe( 22 .pipe(
21 switchMap(video => { 23 switchMap(video => {
22 return this.videoService 24 return forkJoin([
23 .loadCompleteDescription(video.descriptionPath) 25 this.videoService
24 .pipe(map(description => Object.assign(video, { description }))) 26 .loadCompleteDescription(video.descriptionPath)
25 }), 27 .pipe(map(description => Object.assign(video, { description }))),
26 switchMap(video => { 28
27 return this.videoChannelService 29 this.videoChannelService
28 .listAccountVideoChannels(video.account) 30 .listAccountVideoChannels(video.account)
29 .pipe( 31 .pipe(
30 map(result => result.data), 32 map(result => result.data),
31 map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support }))), 33 map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support })))
32 map(videoChannels => ({ video, videoChannels })) 34 ),
33 ) 35
34 }), 36 this.videoCaptionService
35 switchMap(({ video, videoChannels }) => { 37 .listCaptions(video.id)
36 return this.videoCaptionService 38 .pipe(
37 .listCaptions(video.id) 39 map(result => result.data)
38 .pipe( 40 )
39 map(result => result.data), 41 ])
40 map(videoCaptions => ({ video, videoChannels, videoCaptions })) 42 }),
41 ) 43 map(([ video, videoChannels, videoCaptions ]) => ({ video, videoChannels, videoCaptions }))
42 }) 44 )
43 )
44 } 45 }
45} 46}