diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/src/app/+about/about-instance/about-instance.component.ts | 13 | ||||
-rw-r--r-- | client/src/app/+about/about-instance/about-instance.resolver.ts | 15 |
2 files changed, 17 insertions, 11 deletions
diff --git a/client/src/app/+about/about-instance/about-instance.component.ts b/client/src/app/+about/about-instance/about-instance.component.ts index c57ac69ab..bd587fa26 100644 --- a/client/src/app/+about/about-instance/about-instance.component.ts +++ b/client/src/app/+about/about-instance/about-instance.component.ts | |||
@@ -35,12 +35,13 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { | |||
35 | 35 | ||
36 | serverConfig: ServerConfig | 36 | serverConfig: ServerConfig |
37 | 37 | ||
38 | initialized = false | ||
39 | |||
38 | private lastScrollHash: string | 40 | private lastScrollHash: string |
39 | 41 | ||
40 | constructor ( | 42 | constructor ( |
41 | private viewportScroller: ViewportScroller, | 43 | private viewportScroller: ViewportScroller, |
42 | private route: ActivatedRoute, | 44 | private route: ActivatedRoute, |
43 | private serverService: ServerService, | ||
44 | private instanceService: InstanceService | 45 | private instanceService: InstanceService |
45 | ) {} | 46 | ) {} |
46 | 47 | ||
@@ -57,11 +58,9 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { | |||
57 | } | 58 | } |
58 | 59 | ||
59 | async ngOnInit () { | 60 | async ngOnInit () { |
60 | this.serverConfig = this.serverService.getTmpConfig() | 61 | const { about, languages, categories, serverConfig }: ResolverData = this.route.snapshot.data.instanceData |
61 | this.serverService.getConfig() | ||
62 | .subscribe(config => this.serverConfig = config) | ||
63 | 62 | ||
64 | const { about, languages, categories }: ResolverData = this.route.snapshot.data.instanceData | 63 | this.serverConfig = serverConfig |
65 | 64 | ||
66 | this.languages = languages | 65 | this.languages = languages |
67 | this.categories = categories | 66 | this.categories = categories |
@@ -73,10 +72,12 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { | |||
73 | this.businessModel = about.instance.businessModel | 72 | this.businessModel = about.instance.businessModel |
74 | 73 | ||
75 | this.html = await this.instanceService.buildHtml(about) | 74 | this.html = await this.instanceService.buildHtml(about) |
75 | |||
76 | this.initialized = true | ||
76 | } | 77 | } |
77 | 78 | ||
78 | ngAfterViewChecked () { | 79 | ngAfterViewChecked () { |
79 | if (window.location.hash && window.location.hash !== this.lastScrollHash) { | 80 | if (this.initialized && window.location.hash && window.location.hash !== this.lastScrollHash) { |
80 | this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', '')) | 81 | this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', '')) |
81 | 82 | ||
82 | this.lastScrollHash = window.location.hash | 83 | this.lastScrollHash = window.location.hash |
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 b2349ba12..9a5924ebb 100644 --- a/client/src/app/+about/about-instance/about-instance.resolver.ts +++ b/client/src/app/+about/about-instance/about-instance.resolver.ts | |||
@@ -2,15 +2,19 @@ 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 { ActivatedRouteSnapshot, Resolve } from '@angular/router' |
5 | import { ServerService } from '@app/core' | ||
5 | import { InstanceService } from '@app/shared/shared-instance' | 6 | import { InstanceService } from '@app/shared/shared-instance' |
6 | import { About } from '@shared/models/server' | 7 | import { About, ServerConfig } from '@shared/models/server' |
7 | 8 | ||
8 | export type ResolverData = { about: About, languages: string[], categories: string[] } | 9 | export type ResolverData = { about: About, languages: string[], categories: string[], serverConfig: ServerConfig } |
9 | 10 | ||
10 | @Injectable() | 11 | @Injectable() |
11 | export class AboutInstanceResolver implements Resolve<any> { | 12 | export class AboutInstanceResolver implements Resolve<any> { |
12 | 13 | ||
13 | constructor (private instanceService: InstanceService) {} | 14 | constructor ( |
15 | private instanceService: InstanceService, | ||
16 | private serverService: ServerService | ||
17 | ) {} | ||
14 | 18 | ||
15 | resolve (route: ActivatedRouteSnapshot) { | 19 | resolve (route: ActivatedRouteSnapshot) { |
16 | return this.instanceService.getAbout() | 20 | return this.instanceService.getAbout() |
@@ -18,8 +22,9 @@ export class AboutInstanceResolver implements Resolve<any> { | |||
18 | switchMap(about => { | 22 | switchMap(about => { |
19 | return forkJoin([ | 23 | return forkJoin([ |
20 | this.instanceService.buildTranslatedLanguages(about), | 24 | this.instanceService.buildTranslatedLanguages(about), |
21 | this.instanceService.buildTranslatedCategories(about) | 25 | this.instanceService.buildTranslatedCategories(about), |
22 | ]).pipe(map(([ languages, categories ]) => ({ about, languages, categories }))) | 26 | this.serverService.getConfig() |
27 | ]).pipe(map(([ languages, categories, serverConfig ]) => ({ about, languages, categories, serverConfig }))) | ||
23 | }) | 28 | }) |
24 | ) | 29 | ) |
25 | } | 30 | } |