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'
13 export class QuickSettingsModalComponent extends FormReactive implements OnInit {
14 @ViewChild('modal', { static: true }) modal: NgbModal
17 userInformationLoaded = new ReplaySubject<boolean>(1)
19 private openedModal: NgbModalRef
22 protected formValidatorService: FormValidatorService,
23 private modalService: NgbModal,
24 private userService: UserService,
25 private authService: AuthService,
26 private localStorageService: LocalStorageService
32 this.user = this.userService.getAnonymousUser()
33 this.localStorageService.watch()
35 () => 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()