From 12c8a46362f1f92d1c1a34991a76c55f625a80c6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 16 Nov 2020 16:46:15 +0100 Subject: Fix about scrolling behaviour --- .../app/+about/about-instance/about-instance.component.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'client/src/app/+about/about-instance/about-instance.component.ts') 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 { serverConfig: ServerConfig + initialized = false + private lastScrollHash: string constructor ( private viewportScroller: ViewportScroller, private route: ActivatedRoute, - private serverService: ServerService, private instanceService: InstanceService ) {} @@ -57,11 +58,9 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { } async ngOnInit () { - this.serverConfig = this.serverService.getTmpConfig() - this.serverService.getConfig() - .subscribe(config => this.serverConfig = config) + const { about, languages, categories, serverConfig }: ResolverData = this.route.snapshot.data.instanceData - const { about, languages, categories }: ResolverData = this.route.snapshot.data.instanceData + this.serverConfig = serverConfig this.languages = languages this.categories = categories @@ -73,10 +72,12 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { this.businessModel = about.instance.businessModel this.html = await this.instanceService.buildHtml(about) + + this.initialized = true } ngAfterViewChecked () { - if (window.location.hash && window.location.hash !== this.lastScrollHash) { + if (this.initialized && window.location.hash && window.location.hash !== this.lastScrollHash) { this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', '')) this.lastScrollHash = window.location.hash -- cgit v1.2.3