blob: b2349ba12b097fa0cfa080cdefab10a9ccebcf23 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import { forkJoin } from 'rxjs'
import { map, switchMap } from 'rxjs/operators'
import { Injectable } from '@angular/core'
import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
import { InstanceService } from '@app/shared/shared-instance'
import { About } from '@shared/models/server'
export type ResolverData = { about: About, languages: string[], categories: string[] }
@Injectable()
export class AboutInstanceResolver implements Resolve<any> {
constructor (private instanceService: InstanceService) {}
resolve (route: ActivatedRouteSnapshot) {
return this.instanceService.getAbout()
.pipe(
switchMap(about => {
return forkJoin([
this.instanceService.buildTranslatedLanguages(about),
this.instanceService.buildTranslatedCategories(about)
]).pipe(map(([ languages, categories ]) => ({ about, languages, categories })))
})
)
}
}
|