From ba430d7516bc5b1324b60571ba7594460969b7fb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 18 Dec 2019 15:31:54 +0100 Subject: Lazy load static objects --- .../edit-custom-config.component.ts | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'client/src/app/+admin/config') diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index 1f6751297..25e06d8a1 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -8,7 +8,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' import { SelectItem } from 'primeng/api' import { forkJoin } from 'rxjs' -import { first } from 'rxjs/operators' +import { ServerConfig } from '@shared/models' @Component({ selector: 'my-edit-custom-config', @@ -24,6 +24,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { languageItems: SelectItem[] = [] categoryItems: SelectItem[] = [] + private serverConfig: ServerConfig + constructor ( protected formValidatorService: FormValidatorService, private customConfigValidatorsService: CustomConfigValidatorsService, @@ -84,7 +86,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { } get availableThemes () { - return this.serverService.getConfig().theme.registered + return this.serverConfig.theme.registered .map(t => t.name) } @@ -93,6 +95,10 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { } ngOnInit () { + this.serverConfig = this.serverService.getTmpConfig() + this.serverService.getConfig() + .subscribe(config => this.serverConfig = config) + const formGroupData: { [key in keyof CustomConfig ]: any } = { instance: { name: this.customConfigValidatorsService.INSTANCE_NAME, @@ -218,16 +224,13 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { forkJoin([ this.configService.getCustomConfig(), - this.serverService.videoLanguagesLoaded.pipe(first()), // First so the observable completes - this.serverService.videoCategoriesLoaded.pipe(first()) + this.serverService.getVideoLanguages(), + this.serverService.getVideoCategories() ]).subscribe( - ([ config ]) => { + ([ config, languages, categories ]) => { this.customConfig = config - const languages = this.serverService.getVideoLanguages() this.languageItems = languages.map(l => ({ label: l.label, value: l.id })) - - const categories = this.serverService.getVideoCategories() this.categoryItems = categories.map(l => ({ label: l.label, value: l.id })) this.updateForm() @@ -249,12 +252,14 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { async formValidated () { this.configService.updateCustomConfig(this.form.value) + .pipe( + ) .subscribe( res => { this.customConfig = res // Reload general configuration - this.serverService.loadConfig() + this.serverService.resetConfig() this.updateForm() -- cgit v1.2.3