1 import { forkJoin, Observable } from 'rxjs'
2 import { map, switchMap } from 'rxjs/operators'
3 import { Injectable } from '@angular/core'
4 import { ServerService } from '@app/core'
5 import { CustomMarkupService } from '@app/shared/shared-custom-markup'
6 import { AboutHTML, InstanceService } from '@app/shared/shared-instance'
7 import { About, ServerStats } from '@shared/models/server'
9 export type ResolverData = {
10 serverStats: ServerStats
15 descriptionElement: HTMLDivElement
19 export class AboutInstanceResolver {
22 private instanceService: InstanceService,
23 private customMarkupService: CustomMarkupService,
24 private serverService: ServerService
27 resolve (): Observable<ResolverData> {
29 this.buildInstanceAboutObservable(),
30 this.buildInstanceStatsObservable()
33 [ about, languages, categories, aboutHTML, { rootElement } ],
42 descriptionElement: rootElement
48 private buildInstanceAboutObservable () {
49 return this.instanceService.getAbout()
53 Promise.resolve(about),
54 this.instanceService.buildTranslatedLanguages(about),
55 this.instanceService.buildTranslatedCategories(about),
56 this.instanceService.buildHtml(about),
57 this.customMarkupService.buildElement(about.instance.description)
63 private buildInstanceStatsObservable () {
64 return this.serverService.getServerStats()