]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
Fix scrolling with hash in url
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-settings / my-account-change-email / my-account-change-email.component.ts
index ec7cf935c7464d54c773916a0919f0362ac54cd5..9d406805fae8d1ec796bdb1bf20ab8ccf3430693 100644 (file)
@@ -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
+        }
+      )
   }
 }