mirror of https://github.com/Chocobozzz/PeerTube
Optimize video update page load
parent
f3ae606caf
commit
d0dba1fce6
|
@ -4,6 +4,7 @@ import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
|
|||
import { map, switchMap } from 'rxjs/operators'
|
||||
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
|
||||
import { VideoCaptionService } from '@app/shared/video-caption'
|
||||
import { forkJoin } from 'rxjs'
|
||||
|
||||
@Injectable()
|
||||
export class VideoUpdateResolver implements Resolve<any> {
|
||||
|
@ -11,7 +12,8 @@ export class VideoUpdateResolver implements Resolve<any> {
|
|||
private videoService: VideoService,
|
||||
private videoChannelService: VideoChannelService,
|
||||
private videoCaptionService: VideoCaptionService
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
resolve (route: ActivatedRouteSnapshot) {
|
||||
const uuid: string = route.params[ 'uuid' ]
|
||||
|
@ -19,27 +21,26 @@ export class VideoUpdateResolver implements Resolve<any> {
|
|||
return this.videoService.getVideo(uuid)
|
||||
.pipe(
|
||||
switchMap(video => {
|
||||
return this.videoService
|
||||
return forkJoin([
|
||||
this.videoService
|
||||
.loadCompleteDescription(video.descriptionPath)
|
||||
.pipe(map(description => Object.assign(video, { description })))
|
||||
}),
|
||||
switchMap(video => {
|
||||
return this.videoChannelService
|
||||
.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 }))),
|
||||
map(videoChannels => ({ video, videoChannels }))
|
||||
)
|
||||
}),
|
||||
switchMap(({ video, videoChannels }) => {
|
||||
return this.videoCaptionService
|
||||
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(videoCaptions => ({ video, videoChannels, videoCaptions }))
|
||||
map(result => result.data)
|
||||
)
|
||||
})
|
||||
])
|
||||
}),
|
||||
map(([ video, videoChannels, videoCaptions ]) => ({ video, videoChannels, videoCaptions }))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue