1 import { ViewportScroller } from '@angular/common'
2 import { AfterViewChecked, Component, OnInit } from '@angular/core'
3 import { AuthService, Notifier, User, UserService } from '@app/core'
6 selector: 'my-account-settings',
7 templateUrl: './my-account-settings.component.html',
8 styleUrls: [ './my-account-settings.component.scss' ]
10 export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
13 private lastScrollHash: string
16 private viewportScroller: ViewportScroller,
17 private userService: UserService,
18 private authService: AuthService,
19 private notifier: Notifier
22 get userInformationLoaded () {
23 return this.authService.userInformationLoaded
27 this.user = this.authService.getUser()
30 ngAfterViewChecked () {
31 if (window.location.hash && window.location.hash !== this.lastScrollHash) {
32 this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
34 this.lastScrollHash = window.location.hash
38 onAvatarChange (formData: FormData) {
39 this.userService.changeAvatar(formData)
42 this.notifier.success($localize`Avatar changed.`)
44 this.user.updateAccountAvatar(data.avatar)
47 err => this.notifier.error(err.message)