aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+about
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-18 15:31:54 +0100
committerChocobozzz <me@florianbigard.com>2019-12-18 15:40:59 +0100
commitba430d7516bc5b1324b60571ba7594460969b7fb (patch)
treedf5c6952c82f49a94c0a884bbc97d4a0cbd9f867 /client/src/app/+about
parent5dfb7c1dec8222b0bbccac5b56ad46da1438747e (diff)
downloadPeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.gz
PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.zst
PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.zip
Lazy load static objects
Diffstat (limited to 'client/src/app/+about')
-rw-r--r--client/src/app/+about/about-instance/about-instance.component.ts38
-rw-r--r--client/src/app/+about/about-instance/contact-admin-modal.component.ts8
2 files changed, 31 insertions, 15 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 16ccae2e2..87beb13da 100644
--- a/client/src/app/+about/about-instance/about-instance.component.ts
+++ b/client/src/app/+about/about-instance/about-instance.component.ts
@@ -5,7 +5,8 @@ import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-a
5import { InstanceService } from '@app/shared/instance/instance.service' 5import { InstanceService } from '@app/shared/instance/instance.service'
6import { MarkdownService } from '@app/shared/renderer' 6import { MarkdownService } from '@app/shared/renderer'
7import { forkJoin } from 'rxjs' 7import { forkJoin } from 'rxjs'
8import { first } from 'rxjs/operators' 8import { map, switchMap } from 'rxjs/operators'
9import { ServerConfig } from '@shared/models'
9 10
10@Component({ 11@Component({
11 selector: 'my-about-instance', 12 selector: 'my-about-instance',
@@ -33,6 +34,8 @@ export class AboutInstanceComponent implements OnInit {
33 languages: string[] = [] 34 languages: string[] = []
34 categories: string[] = [] 35 categories: string[] = []
35 36
37 serverConfig: ServerConfig
38
36 constructor ( 39 constructor (
37 private notifier: Notifier, 40 private notifier: Notifier,
38 private serverService: ServerService, 41 private serverService: ServerService,
@@ -42,25 +45,35 @@ export class AboutInstanceComponent implements OnInit {
42 ) {} 45 ) {}
43 46
44 get instanceName () { 47 get instanceName () {
45 return this.serverService.getConfig().instance.name 48 return this.serverConfig.instance.name
46 } 49 }
47 50
48 get isContactFormEnabled () { 51 get isContactFormEnabled () {
49 return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled 52 return this.serverConfig.email.enabled && this.serverConfig.contactForm.enabled
50 } 53 }
51 54
52 get isNSFW () { 55 get isNSFW () {
53 return this.serverService.getConfig().instance.isNSFW 56 return this.serverConfig.instance.isNSFW
54 } 57 }
55 58
56 ngOnInit () { 59 ngOnInit () {
57 forkJoin([ 60 this.serverConfig = this.serverService.getTmpConfig()
58 this.instanceService.getAbout(), 61 this.serverService.getConfig()
59 this.serverService.localeObservable.pipe(first()), 62 .subscribe(config => this.serverConfig = config)
60 this.serverService.videoLanguagesLoaded.pipe(first()), 63
61 this.serverService.videoCategoriesLoaded.pipe(first()) 64 this.instanceService.getAbout()
62 ]).subscribe( 65 .pipe(
63 async ([ about, translations ]) => { 66 switchMap(about => {
67 return forkJoin([
68 this.instanceService.buildTranslatedLanguages(about),
69 this.instanceService.buildTranslatedCategories(about)
70 ]).pipe(map(([ languages, categories ]) => ({ about, languages, categories })))
71 })
72 ).subscribe(
73 async ({ about, languages, categories }) => {
74 this.languages = languages
75 this.categories = categories
76
64 this.shortDescription = about.instance.shortDescription 77 this.shortDescription = about.instance.shortDescription
65 78
66 this.creationReason = about.instance.creationReason 79 this.creationReason = about.instance.creationReason
@@ -68,9 +81,6 @@ export class AboutInstanceComponent implements OnInit {
68 this.businessModel = about.instance.businessModel 81 this.businessModel = about.instance.businessModel
69 82
70 this.html = await this.instanceService.buildHtml(about) 83 this.html = await this.instanceService.buildHtml(about)
71
72 this.languages = this.instanceService.buildTranslatedLanguages(about, translations)
73 this.categories = this.instanceService.buildTranslatedCategories(about, translations)
74 }, 84 },
75 85
76 () => this.notifier.error(this.i18n('Cannot get about information from server')) 86 () => this.notifier.error(this.i18n('Cannot get about information from server'))
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 878d49b55..2ed41e741 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
@@ -6,6 +6,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
6import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 6import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
7import { FormReactive, InstanceValidatorsService } from '@app/shared' 7import { FormReactive, InstanceValidatorsService } from '@app/shared'
8import { InstanceService } from '@app/shared/instance/instance.service' 8import { InstanceService } from '@app/shared/instance/instance.service'
9import { ServerConfig } from '@shared/models'
9 10
10@Component({ 11@Component({
11 selector: 'my-contact-admin-modal', 12 selector: 'my-contact-admin-modal',
@@ -18,6 +19,7 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
18 error: string 19 error: string
19 20
20 private openedModal: NgbModalRef 21 private openedModal: NgbModalRef
22 private serverConfig: ServerConfig
21 23
22 constructor ( 24 constructor (
23 protected formValidatorService: FormValidatorService, 25 protected formValidatorService: FormValidatorService,
@@ -32,10 +34,14 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
32 } 34 }
33 35
34 get instanceName () { 36 get instanceName () {
35 return this.serverService.getConfig().instance.name 37 return this.serverConfig.instance.name
36 } 38 }
37 39
38 ngOnInit () { 40 ngOnInit () {
41 this.serverConfig = this.serverService.getTmpConfig()
42 this.serverService.getConfig()
43 .subscribe(config => this.serverConfig = config)
44
39 this.buildForm({ 45 this.buildForm({
40 fromName: this.instanceValidatorsService.FROM_NAME, 46 fromName: this.instanceValidatorsService.FROM_NAME,
41 fromEmail: this.instanceValidatorsService.FROM_EMAIL, 47 fromEmail: this.instanceValidatorsService.FROM_EMAIL,