1 import { ReplaySubject } from 'rxjs'
2 import { filter } from 'rxjs/operators'
3 import { Component, OnInit, ViewChild } from '@angular/core'
4 import { AuthService, AuthStatus, LocalStorageService, User, UserService } from '@app/core'
5 import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
6 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
7 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
10 selector: 'my-quick-settings',
11 templateUrl: './quick-settings-modal.component.html',
12 styleUrls: [ './quick-settings-modal.component.scss' ]
14 export class QuickSettingsModalComponent extends FormReactive implements OnInit {
15 @ViewChild('modal', { static: true }) modal: NgbModal
18 userInformationLoaded = new ReplaySubject<boolean>(1)
20 private openedModal: NgbModalRef
23 protected formValidatorService: FormValidatorService,
24 private modalService: NgbModal,
25 private userService: UserService,
26 private authService: AuthService,
27 private localStorageService: LocalStorageService
33 this.user = this.userService.getAnonymousUser()
34 this.localStorageService.watch()
36 () => this.user = this.userService.getAnonymousUser()
39 this.userInformationLoaded.next(true)
41 this.authService.loginChangedSource
42 .pipe(filter(status => status !== AuthStatus.LoggedIn))
45 this.user = this.userService.getAnonymousUser()
46 this.userInformationLoaded.next(true)
52 return this.authService.isLoggedIn()
56 this.openedModal = this.modalService.open(this.modal, { centered: true })
60 this.openedModal.close()