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 --- .../my-account-change-email.component.ts | 43 +++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'client/src/app/+my-account/my-account-settings/my-account-change-email') diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts index ec7cf935c..9d406805f 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts @@ -6,6 +6,7 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' import { User } from '../../../../../../shared' import { tap } from 'rxjs/operators' +import { forkJoin } from 'rxjs' @Component({ selector: 'my-account-change-email', @@ -45,29 +46,29 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni const password = this.form.value[ 'password' ] const email = this.form.value[ 'new-email' ] - this.userService.changeEmail(password, email) - .pipe( - tap(() => this.authService.refreshUserInformation()) - ) - .subscribe( - () => { - this.form.reset() + forkJoin([ + this.serverService.getConfig(), + this.userService.changeEmail(password, email) + ]).pipe(tap(() => this.authService.refreshUserInformation())) + .subscribe( + ([ config ]) => { + this.form.reset() - if (this.serverService.getConfig().signup.requiresEmailVerification) { - this.success = this.i18n('Please check your emails to verify your new email.') - } else { - this.success = this.i18n('Email updated.') - } - }, - - err => { - if (err.status === 401) { - this.error = this.i18n('You current password is invalid.') - return - } + if (config.signup.requiresEmailVerification) { + this.success = this.i18n('Please check your emails to verify your new email.') + } else { + this.success = this.i18n('Email updated.') + } + }, - this.error = err.message + err => { + if (err.status === 401) { + this.error = this.i18n('You current password is invalid.') + return } - ) + + this.error = err.message + } + ) } } -- cgit v1.2.3