diff options
author | Chocobozzz <me@florianbigard.com> | 2020-02-03 10:31:34 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-02-03 10:33:08 +0100 |
commit | b42f9c400e7b677046ab0034a3cf7aaaa73ecb6d (patch) | |
tree | dd00268a13ef51c77ceaaeb2ffbcd874e6f177df /client/src/app/+about/about-instance/about-instance.resolver.ts | |
parent | a15871560f80e07386c1dabb8370cd2664ecfd1f (diff) | |
download | PeerTube-b42f9c400e7b677046ab0034a3cf7aaaa73ecb6d.tar.gz PeerTube-b42f9c400e7b677046ab0034a3cf7aaaa73ecb6d.tar.zst PeerTube-b42f9c400e7b677046ab0034a3cf7aaaa73ecb6d.zip |
Use a resolver for the about page
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 | 27 |
1 files changed, 27 insertions, 0 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 new file mode 100644 index 000000000..94c6abe5a --- /dev/null +++ b/client/src/app/+about/about-instance/about-instance.resolver.ts | |||
@@ -0,0 +1,27 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import { ActivatedRouteSnapshot, Resolve } from '@angular/router' | ||
3 | import { map, switchMap } from 'rxjs/operators' | ||
4 | import { forkJoin } from 'rxjs' | ||
5 | import { InstanceService } from '@app/shared/instance/instance.service' | ||
6 | import { About } from '@shared/models/server' | ||
7 | |||
8 | export type ResolverData = { about: About, languages: string[], categories: string[] } | ||
9 | |||
10 | @Injectable() | ||
11 | export class AboutInstanceResolver implements Resolve<any> { | ||
12 | constructor ( | ||
13 | private instanceService: InstanceService | ||
14 | ) {} | ||
15 | |||
16 | resolve (route: ActivatedRouteSnapshot) { | ||
17 | return this.instanceService.getAbout() | ||
18 | .pipe( | ||
19 | switchMap(about => { | ||
20 | return forkJoin([ | ||
21 | this.instanceService.buildTranslatedLanguages(about), | ||
22 | this.instanceService.buildTranslatedCategories(about) | ||
23 | ]).pipe(map(([ languages, categories ]) => ({ about, languages, categories }))) | ||
24 | }) | ||
25 | ) | ||
26 | } | ||
27 | } | ||