]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-user-settings/user-interface-settings.component.ts
Merge branch 'release/4.1.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-user-settings / user-interface-settings.component.ts
index 80b88c12978079cdc9f6ceccd8a3a01acca0c84f..d04a2c3488cd4ecf84afa33dc8ce1f14ccdb725a 100644 (file)
@@ -2,7 +2,7 @@ import { Subject, Subscription } from 'rxjs'
 import { Component, Input, OnDestroy, OnInit } from '@angular/core'
 import { AuthService, Notifier, ServerService, UserService } from '@app/core'
 import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
-import { ServerConfig, User, UserUpdateMe } from '@shared/models'
+import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models'
 
 @Component({
   selector: 'my-user-interface-settings',
@@ -17,7 +17,7 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
 
   formValuesWatcher: Subscription
 
-  private serverConfig: ServerConfig
+  private serverConfig: HTMLServerConfig
 
   constructor (
     protected formValidatorService: FormValidatorService,
@@ -35,9 +35,7 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
   }
 
   ngOnInit () {
-    this.serverConfig = this.serverService.getTmpConfig()
-    this.serverService.getConfig()
-        .subscribe(config => this.serverConfig = config)
+    this.serverConfig = this.serverService.getHTMLConfig()
 
     this.buildForm({
       theme: null
@@ -50,7 +48,7 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
         })
 
         if (this.reactiveUpdate) {
-          this.formValuesWatcher = this.form.valueChanges.subscribe(val => this.updateInterfaceSettings())
+          this.formValuesWatcher = this.form.valueChanges.subscribe(() => this.updateInterfaceSettings())
         }
       })
   }
@@ -67,18 +65,21 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
     }
 
     if (this.authService.isLoggedIn()) {
-      this.userService.updateMyProfile(details).subscribe(
-        () => {
-          this.authService.refreshUserInformation()
-
-          if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`)
-        },
-
-        err => this.notifier.error(err.message)
-      )
-    } else {
-      this.userService.updateMyAnonymousProfile(details)
-      if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`)
+      this.userService.updateMyProfile(details)
+        .subscribe({
+          next: () => {
+            this.authService.refreshUserInformation()
+
+            if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`)
+          },
+
+          error: err => this.notifier.error(err.message)
+        })
+
+      return
     }
+
+    this.userService.updateMyAnonymousProfile(details)
+    if (this.notifyOnUpdate) this.notifier.success($localize`Interface settings updated.`)
   }
 }