1 import { Component, ViewChild, OnInit } from '@angular/core'
2 import { AuthService, AuthStatus } from '@app/core'
3 import { FormReactive, FormValidatorService, UserService, User } from '@app/shared'
4 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
5 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
6 import { ReplaySubject } from 'rxjs'
7 import { LocalStorageService } from '@app/shared/misc/storage.service'
8 import { filter } from 'rxjs/operators'
11 selector: 'my-quick-settings',
12 templateUrl: './quick-settings-modal.component.html',
13 styleUrls: [ './quick-settings-modal.component.scss' ]
15 export class QuickSettingsModalComponent extends FormReactive implements OnInit {
16 @ViewChild('modal', { static: true }) modal: NgbModal
19 userInformationLoaded = new ReplaySubject<boolean>(1)
21 private openedModal: NgbModalRef
24 protected formValidatorService: FormValidatorService,
25 private modalService: NgbModal,
26 private userService: UserService,
27 private authService: AuthService,
28 private localStorageService: LocalStorageService
34 this.user = this.userService.getAnonymousUser()
35 this.localStorageService.watch().subscribe(
36 () => this.user = this.userService.getAnonymousUser()
38 this.userInformationLoaded.next(true)
40 this.authService.loginChangedSource
41 .pipe(filter(status => status !== AuthStatus.LoggedIn))
44 this.user = this.userService.getAnonymousUser()
45 this.userInformationLoaded.next(true)
51 return this.authService.isLoggedIn()
55 this.openedModal = this.modalService.open(this.modal, { centered: true })
59 this.openedModal.close()