1 import { forkJoin, Observable } from 'rxjs'
2 import { map, switchMap } from 'rxjs/operators'
3 import { Injectable } from '@angular/core'
4 import { Resolve } from '@angular/router'
5 import { ServerService } from '@app/core'
6 import { CustomMarkupService } from '@app/shared/shared-custom-markup'
7 import { AboutHTML, InstanceService } from '@app/shared/shared-instance'
8 import { About, ServerStats } from '@shared/models/server'
10 export type ResolverData = {
11 serverStats: ServerStats
16 descriptionElement: HTMLDivElement
20 export class AboutInstanceResolver implements Resolve<any> {
23 private instanceService: InstanceService,
24 private customMarkupService: CustomMarkupService,
25 private serverService: ServerService
28 resolve (): Observable<ResolverData> {
30 this.buildInstanceAboutObservable(),
31 this.buildInstanceStatsObservable()
34 [ about, languages, categories, aboutHTML, { rootElement } ],
43 descriptionElement: rootElement
49 private buildInstanceAboutObservable () {
50 return this.instanceService.getAbout()
54 Promise.resolve(about),
55 this.instanceService.buildTranslatedLanguages(about),
56 this.instanceService.buildTranslatedCategories(about),
57 this.instanceService.buildHtml(about),
58 this.customMarkupService.buildElement(about.instance.description)
64 private buildInstanceStatsObservable () {
65 return this.serverService.getServerStats()