1 import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
2 import { AuthService, ServerService, User, UserService } from '@app/core'
3 import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
4 import { HTMLServerConfig } from '@shared/models'
7 selector: 'my-account-setup-modal',
8 templateUrl: './account-setup-modal.component.html',
9 styleUrls: [ './account-setup-modal.component.scss' ]
11 export class AccountSetupModalComponent implements OnInit {
12 @ViewChild('modal', { static: true }) modal: ElementRef
15 ref: NgbModalRef = null
17 private serverConfig: HTMLServerConfig
20 private userService: UserService,
21 private authService: AuthService,
22 private modalService: NgbModal,
23 private serverService: ServerService
26 get userInformationLoaded () {
27 return this.authService.userInformationLoaded
31 return this.serverConfig.instance.name
35 return this.user.username === 'root'
38 get hasAccountAvatar () {
39 return !!this.user.account.avatar
42 get hasAccountDescription () {
43 return !!this.user.account.description
47 this.serverConfig = this.serverService.getHTMLConfig()
49 this.authService.userInformationLoaded
52 this.user = this.authService.getUser()
54 if (this.isUserRoot) return
55 if (this.hasAccountAvatar && this.hasAccountDescription) return
56 if (this.userService.hasSignupInThisSession()) return
66 this.ref = this.modalService.open(this.modal, {