aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+about/about-instance/about-instance.resolver.ts
diff options
context:
space:
mode:
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.ts62
1 files changed, 43 insertions, 19 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 8818fc582..94388e71d 100644
--- a/client/src/app/+about/about-instance/about-instance.resolver.ts
+++ b/client/src/app/+about/about-instance/about-instance.resolver.ts
@@ -1,12 +1,14 @@
1import { forkJoin } from 'rxjs' 1import { forkJoin, Observable } from 'rxjs'
2import { map, switchMap } from 'rxjs/operators' 2import { map, switchMap } from 'rxjs/operators'
3import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
4import { Resolve } from '@angular/router' 4import { Resolve } from '@angular/router'
5import { ServerService } from '@app/core'
5import { CustomMarkupService } from '@app/shared/shared-custom-markup' 6import { CustomMarkupService } from '@app/shared/shared-custom-markup'
6import { AboutHTML, InstanceService } from '@app/shared/shared-instance' 7import { AboutHTML, InstanceService } from '@app/shared/shared-instance'
7import { About } from '@shared/models/server' 8import { About, ServerStats } from '@shared/models/server'
8 9
9export type ResolverData = { 10export type ResolverData = {
11 serverStats: ServerStats
10 about: About 12 about: About
11 languages: string[] 13 languages: string[]
12 categories: string[] 14 categories: string[]
@@ -19,25 +21,47 @@ export class AboutInstanceResolver implements Resolve<any> {
19 21
20 constructor ( 22 constructor (
21 private instanceService: InstanceService, 23 private instanceService: InstanceService,
22 private customMarkupService: CustomMarkupService 24 private customMarkupService: CustomMarkupService,
23 25 private serverService: ServerService
24 ) {} 26 ) {}
25 27
26 resolve () { 28 resolve (): Observable<ResolverData> {
29 return forkJoin([
30 this.buildInstanceAboutObservable(),
31 this.buildInstanceStatsObservable()
32 ]).pipe(
33 map(([
34 [ about, languages, categories, aboutHTML, { rootElement } ],
35 serverStats
36 ]) => {
37 return {
38 serverStats,
39 about,
40 languages,
41 categories,
42 aboutHTML,
43 descriptionElement: rootElement
44 }
45 })
46 )
47 }
48
49 private buildInstanceAboutObservable () {
27 return this.instanceService.getAbout() 50 return this.instanceService.getAbout()
28 .pipe( 51 .pipe(
29 switchMap(about => { 52 switchMap(about => {
30 return forkJoin([ 53 return forkJoin([
31 Promise.resolve(about), 54 Promise.resolve(about),
32 this.instanceService.buildTranslatedLanguages(about), 55 this.instanceService.buildTranslatedLanguages(about),
33 this.instanceService.buildTranslatedCategories(about), 56 this.instanceService.buildTranslatedCategories(about),
34 this.instanceService.buildHtml(about), 57 this.instanceService.buildHtml(about),
35 this.customMarkupService.buildElement(about.instance.description) 58 this.customMarkupService.buildElement(about.instance.description)
36 ]) 59 ])
37 }), 60 })
38 map(([ about, languages, categories, aboutHTML, { rootElement } ]) => { 61 )
39 return { about, languages, categories, aboutHTML, descriptionElement: rootElement } as ResolverData 62 }
40 }) 63
41 ) 64 private buildInstanceStatsObservable () {
65 return this.serverService.getServerStats()
42 } 66 }
43} 67}