diff options
Diffstat (limited to 'client/src/app/+about/about-instance/about-instance.resolver.ts')
-rw-r--r-- | client/src/app/+about/about-instance/about-instance.resolver.ts | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/client/src/app/+about/about-instance/about-instance.resolver.ts b/client/src/app/+about/about-instance/about-instance.resolver.ts index 9a5924ebb..ee0219df0 100644 --- a/client/src/app/+about/about-instance/about-instance.resolver.ts +++ b/client/src/app/+about/about-instance/about-instance.resolver.ts | |||
@@ -1,30 +1,27 @@ | |||
1 | import { forkJoin } from 'rxjs' | 1 | import { forkJoin } from 'rxjs' |
2 | import { map, switchMap } from 'rxjs/operators' | 2 | import { map, switchMap } from 'rxjs/operators' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { ActivatedRouteSnapshot, Resolve } from '@angular/router' | 4 | import { Resolve } from '@angular/router' |
5 | import { ServerService } from '@app/core' | ||
6 | import { InstanceService } from '@app/shared/shared-instance' | 5 | import { InstanceService } from '@app/shared/shared-instance' |
7 | import { About, ServerConfig } from '@shared/models/server' | 6 | import { About } from '@shared/models/server' |
8 | 7 | ||
9 | export type ResolverData = { about: About, languages: string[], categories: string[], serverConfig: ServerConfig } | 8 | export type ResolverData = { about: About, languages: string[], categories: string[] } |
10 | 9 | ||
11 | @Injectable() | 10 | @Injectable() |
12 | export class AboutInstanceResolver implements Resolve<any> { | 11 | export class AboutInstanceResolver implements Resolve<any> { |
13 | 12 | ||
14 | constructor ( | 13 | constructor ( |
15 | private instanceService: InstanceService, | 14 | private instanceService: InstanceService |
16 | private serverService: ServerService | ||
17 | ) {} | 15 | ) {} |
18 | 16 | ||
19 | resolve (route: ActivatedRouteSnapshot) { | 17 | resolve () { |
20 | return this.instanceService.getAbout() | 18 | return this.instanceService.getAbout() |
21 | .pipe( | 19 | .pipe( |
22 | switchMap(about => { | 20 | switchMap(about => { |
23 | return forkJoin([ | 21 | return forkJoin([ |
24 | this.instanceService.buildTranslatedLanguages(about), | 22 | this.instanceService.buildTranslatedLanguages(about), |
25 | this.instanceService.buildTranslatedCategories(about), | 23 | this.instanceService.buildTranslatedCategories(about) |
26 | this.serverService.getConfig() | 24 | ]).pipe(map(([ languages, categories ]) => ({ about, languages, categories }) as ResolverData)) |
27 | ]).pipe(map(([ languages, categories, serverConfig ]) => ({ about, languages, categories, serverConfig }))) | ||
28 | }) | 25 | }) |
29 | ) | 26 | ) |
30 | } | 27 | } |