aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+about
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-16 16:46:15 +0100
committerChocobozzz <me@florianbigard.com>2020-11-16 16:46:15 +0100
commit12c8a46362f1f92d1c1a34991a76c55f625a80c6 (patch)
tree7bd51d84845359d6ce821033b8898687a6ff757f /client/src/app/+about
parenta75eb7489c92869a7ca46d0c484fccdecc3ed7a2 (diff)
downloadPeerTube-12c8a46362f1f92d1c1a34991a76c55f625a80c6.tar.gz
PeerTube-12c8a46362f1f92d1c1a34991a76c55f625a80c6.tar.zst
PeerTube-12c8a46362f1f92d1c1a34991a76c55f625a80c6.zip
Fix about scrolling behaviour
Diffstat (limited to 'client/src/app/+about')
-rw-r--r--client/src/app/+about/about-instance/about-instance.component.ts13
-rw-r--r--client/src/app/+about/about-instance/about-instance.resolver.ts15
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'
2import { map, switchMap } from 'rxjs/operators' 2import { map, switchMap } from 'rxjs/operators'
3import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
4import { ActivatedRouteSnapshot, Resolve } from '@angular/router' 4import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
5import { ServerService } from '@app/core'
5import { InstanceService } from '@app/shared/shared-instance' 6import { InstanceService } from '@app/shared/shared-instance'
6import { About } from '@shared/models/server' 7import { About, ServerConfig } from '@shared/models/server'
7 8
8export type ResolverData = { about: About, languages: string[], categories: string[] } 9export type ResolverData = { about: About, languages: string[], categories: string[], serverConfig: ServerConfig }
9 10
10@Injectable() 11@Injectable()
11export class AboutInstanceResolver implements Resolve<any> { 12export 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 }