aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+about/about-instance
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-04 13:31:41 +0200
committerChocobozzz <me@florianbigard.com>2021-06-04 15:45:44 +0200
commit2989628b7913383b39ac34c7db8666a21f8e5037 (patch)
treeac7759177c04e524e7845143fd685aefb49e810e /client/src/app/+about/about-instance
parent8e08d415f9473b6b72fef698729453e726da16e7 (diff)
downloadPeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.tar.gz
PeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.tar.zst
PeerTube-2989628b7913383b39ac34c7db8666a21f8e5037.zip
Use HTML config when possible
Diffstat (limited to 'client/src/app/+about/about-instance')
-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.ts17
-rw-r--r--client/src/app/+about/about-instance/contact-admin-modal.component.ts8
3 files changed, 17 insertions, 21 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 5627aaa5a..f02048f39 100644
--- a/client/src/app/+about/about-instance/about-instance.component.ts
+++ b/client/src/app/+about/about-instance/about-instance.component.ts
@@ -2,10 +2,10 @@ import { ViewportScroller } from '@angular/common'
2import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core' 2import { AfterViewChecked, Component, ElementRef, OnInit, ViewChild } from '@angular/core'
3import { ActivatedRoute } from '@angular/router' 3import { ActivatedRoute } from '@angular/router'
4import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' 4import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component'
5import { Notifier } from '@app/core' 5import { Notifier, ServerService } from '@app/core'
6import { CustomMarkupService } from '@app/shared/shared-custom-markup' 6import { CustomMarkupService } from '@app/shared/shared-custom-markup'
7import { InstanceService } from '@app/shared/shared-instance' 7import { InstanceService } from '@app/shared/shared-instance'
8import { About, ServerConfig } from '@shared/models' 8import { About, HTMLServerConfig, ServerConfig } from '@shared/models'
9import { copyToClipboard } from '../../../root-helpers/utils' 9import { copyToClipboard } from '../../../root-helpers/utils'
10import { ResolverData } from './about-instance.resolver' 10import { ResolverData } from './about-instance.resolver'
11 11
@@ -35,16 +35,17 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked {
35 languages: string[] = [] 35 languages: string[] = []
36 categories: string[] = [] 36 categories: string[] = []
37 37
38 serverConfig: ServerConfig
39
40 initialized = false 38 initialized = false
41 39
40 private serverConfig: HTMLServerConfig
41
42 private lastScrollHash: string 42 private lastScrollHash: string
43 43
44 constructor ( 44 constructor (
45 private viewportScroller: ViewportScroller, 45 private viewportScroller: ViewportScroller,
46 private route: ActivatedRoute, 46 private route: ActivatedRoute,
47 private notifier: Notifier, 47 private notifier: Notifier,
48 private serverService: ServerService,
48 private instanceService: InstanceService 49 private instanceService: InstanceService
49 ) {} 50 ) {}
50 51
@@ -61,9 +62,9 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked {
61 } 62 }
62 63
63 async ngOnInit () { 64 async ngOnInit () {
64 const { about, languages, categories, serverConfig }: ResolverData = this.route.snapshot.data.instanceData 65 const { about, languages, categories }: ResolverData = this.route.snapshot.data.instanceData
65 66
66 this.serverConfig = serverConfig 67 this.serverConfig = this.serverService.getHTMLConfig()
67 68
68 this.languages = languages 69 this.languages = languages
69 this.categories = categories 70 this.categories = categories
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 9a5924ebb..ee0219df0 100644
--- a/client/src/app/+about/about-instance/about-instance.resolver.ts
+++ b/client/src/app/+about/about-instance/about-instance.resolver.ts
@@ -1,30 +1,27 @@
1import { forkJoin } from 'rxjs' 1import { 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 { Resolve } from '@angular/router'
5import { ServerService } from '@app/core'
6import { InstanceService } from '@app/shared/shared-instance' 5import { InstanceService } from '@app/shared/shared-instance'
7import { About, ServerConfig } from '@shared/models/server' 6import { About } from '@shared/models/server'
8 7
9export type ResolverData = { about: About, languages: string[], categories: string[], serverConfig: ServerConfig } 8export type ResolverData = { about: About, languages: string[], categories: string[] }
10 9
11@Injectable() 10@Injectable()
12export class AboutInstanceResolver implements Resolve<any> { 11export class AboutInstanceResolver implements Resolve<any> {
13 12
14 constructor ( 13 constructor (
15 private instanceService: InstanceService, 14 private instanceService: InstanceService
16 private serverService: ServerService
17 ) {} 15 ) {}
18 16
19 resolve (route: ActivatedRouteSnapshot) { 17 resolve () {
20 return this.instanceService.getAbout() 18 return this.instanceService.getAbout()
21 .pipe( 19 .pipe(
22 switchMap(about => { 20 switchMap(about => {
23 return forkJoin([ 21 return forkJoin([
24 this.instanceService.buildTranslatedLanguages(about), 22 this.instanceService.buildTranslatedLanguages(about),
25 this.instanceService.buildTranslatedCategories(about), 23 this.instanceService.buildTranslatedCategories(about)
26 this.serverService.getConfig() 24 ]).pipe(map(([ languages, categories ]) => ({ about, languages, categories }) as ResolverData))
27 ]).pipe(map(([ languages, categories, serverConfig ]) => ({ about, languages, categories, serverConfig })))
28 }) 25 })
29 ) 26 )
30 } 27 }
diff --git a/client/src/app/+about/about-instance/contact-admin-modal.component.ts b/client/src/app/+about/about-instance/contact-admin-modal.component.ts
index ac2a6c980..adbe7fe9a 100644
--- a/client/src/app/+about/about-instance/contact-admin-modal.component.ts
+++ b/client/src/app/+about/about-instance/contact-admin-modal.component.ts
@@ -11,7 +11,7 @@ import { InstanceService } from '@app/shared/shared-instance'
11import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 11import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
12import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 12import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
13import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 13import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
14import { ServerConfig } from '@shared/models' 14import { HTMLServerConfig } from '@shared/models'
15 15
16@Component({ 16@Component({
17 selector: 'my-contact-admin-modal', 17 selector: 'my-contact-admin-modal',
@@ -24,7 +24,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
24 error: string 24 error: string
25 25
26 private openedModal: NgbModalRef 26 private openedModal: NgbModalRef
27 private serverConfig: ServerConfig 27 private serverConfig: HTMLServerConfig
28 28
29 constructor ( 29 constructor (
30 protected formValidatorService: FormValidatorService, 30 protected formValidatorService: FormValidatorService,
@@ -41,9 +41,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
41 } 41 }
42 42
43 ngOnInit () { 43 ngOnInit () {
44 this.serverConfig = this.serverService.getTmpConfig() 44 this.serverConfig = this.serverService.getHTMLConfig()
45 this.serverService.getConfig()
46 .subscribe(config => this.serverConfig = config)
47 45
48 this.buildForm({ 46 this.buildForm({
49 fromName: FROM_NAME_VALIDATOR, 47 fromName: FROM_NAME_VALIDATOR,