aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-edit/video-update.resolver.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-16 18:09:31 +0200
committerChocobozzz <me@florianbigard.com>2018-07-16 18:09:31 +0200
commit308c427551c3e20cd9172be58636d8c178f5ae70 (patch)
tree10c96e81ccf8da8f7460fc76f90963e3a7f6ac9c /client/src/app/videos/+video-edit/video-update.resolver.ts
parentef4c78da4f0da61aebfa42f6e8420bf431a68bc8 (diff)
downloadPeerTube-308c427551c3e20cd9172be58636d8c178f5ae70.tar.gz
PeerTube-308c427551c3e20cd9172be58636d8c178f5ae70.tar.zst
PeerTube-308c427551c3e20cd9172be58636d8c178f5ae70.zip
Use a resolver when updating the video
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.ts45
1 files changed, 45 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..269fe3684
--- /dev/null
+++ b/client/src/app/videos/+video-edit/video-update.resolver.ts
@@ -0,0 +1,45 @@
1import { Injectable } from '@angular/core'
2import { VideoService } from '@app/shared/video/video.service'
3import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
4import { map, switchMap } from 'rxjs/operators'
5import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
6import { VideoCaptionService } from '@app/shared/video-caption'
7
8@Injectable()
9export class VideoUpdateResolver implements Resolve<any> {
10 constructor (
11 private videoService: VideoService,
12 private videoChannelService: VideoChannelService,
13 private videoCaptionService: VideoCaptionService
14 ) {}
15
16 resolve (route: ActivatedRouteSnapshot) {
17 const uuid: string = route.params[ 'uuid' ]
18
19 return this.videoService.getVideo(uuid)
20 .pipe(
21 switchMap(video => {
22 return this.videoService
23 .loadCompleteDescription(video.descriptionPath)
24 .pipe(map(description => Object.assign(video, { description })))
25 }),
26 switchMap(video => {
27 return 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 map(videoChannels => ({ video, videoChannels }))
33 )
34 }),
35 switchMap(({ video, videoChannels }) => {
36 return this.videoCaptionService
37 .listCaptions(video.id)
38 .pipe(
39 map(result => result.data),
40 map(videoCaptions => ({ video, videoChannels, videoCaptions }))
41 )
42 })
43 )
44 }
45}