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',
formValuesWatcher: Subscription
- private serverConfig: ServerConfig
+ private serverConfig: HTMLServerConfig
constructor (
protected formValidatorService: FormValidatorService,
}
ngOnInit () {
- this.serverConfig = this.serverService.getTmpConfig()
- this.serverService.getConfig()
- .subscribe(config => this.serverConfig = config)
+ this.serverConfig = this.serverService.getHTMLConfig()
this.buildForm({
theme: null
})
if (this.reactiveUpdate) {
- this.formValuesWatcher = this.form.valueChanges.subscribe(val => this.updateInterfaceSettings())
+ this.formValuesWatcher = this.form.valueChanges.subscribe(() => this.updateInterfaceSettings())
}
})
}
}
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.`)
}
}