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 { map, switchMap } from 'rxjs/operators'
|
||||||
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
|
import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
|
||||||
import { VideoCaptionService } from '@app/shared/video-caption'
|
import { VideoCaptionService } from '@app/shared/video-caption'
|
||||||
|
import { forkJoin } from 'rxjs'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class VideoUpdateResolver implements Resolve<any> {
|
export class VideoUpdateResolver implements Resolve<any> {
|
||||||
|
@ -11,35 +12,35 @@ export class VideoUpdateResolver implements Resolve<any> {
|
||||||
private videoService: VideoService,
|
private videoService: VideoService,
|
||||||
private videoChannelService: VideoChannelService,
|
private videoChannelService: VideoChannelService,
|
||||||
private videoCaptionService: VideoCaptionService
|
private videoCaptionService: VideoCaptionService
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
resolve (route: ActivatedRouteSnapshot) {
|
resolve (route: ActivatedRouteSnapshot) {
|
||||||
const uuid: string = route.params[ 'uuid' ]
|
const uuid: string = route.params[ 'uuid' ]
|
||||||
|
|
||||||
return this.videoService.getVideo(uuid)
|
return this.videoService.getVideo(uuid)
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap(video => {
|
switchMap(video => {
|
||||||
return this.videoService
|
return forkJoin([
|
||||||
.loadCompleteDescription(video.descriptionPath)
|
this.videoService
|
||||||
.pipe(map(description => Object.assign(video, { description })))
|
.loadCompleteDescription(video.descriptionPath)
|
||||||
}),
|
.pipe(map(description => Object.assign(video, { description }))),
|
||||||
switchMap(video => {
|
|
||||||
return this.videoChannelService
|
this.videoChannelService
|
||||||
.listAccountVideoChannels(video.account)
|
.listAccountVideoChannels(video.account)
|
||||||
.pipe(
|
.pipe(
|
||||||
map(result => result.data),
|
map(result => result.data),
|
||||||
map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support }))),
|
map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support })))
|
||||||
map(videoChannels => ({ video, videoChannels }))
|
),
|
||||||
)
|
|
||||||
}),
|
this.videoCaptionService
|
||||||
switchMap(({ video, videoChannels }) => {
|
.listCaptions(video.id)
|
||||||
return this.videoCaptionService
|
.pipe(
|
||||||
.listCaptions(video.id)
|
map(result => result.data)
|
||||||
.pipe(
|
)
|
||||||
map(result => result.data),
|
])
|
||||||
map(videoCaptions => ({ video, videoChannels, videoCaptions }))
|
}),
|
||||||
)
|
map(([ video, videoChannels, videoCaptions ]) => ({ video, videoChannels, videoCaptions }))
|
||||||
})
|
)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue