import { ChangeDetectionStrategy , ChangeDetectorRef , Component , OnDestroy , OnInit , } from '@angular/core' ; import { Session } from '../../../services/session' ; import { Observable , Subscription } from 'rxjs' ; import { ConfigsService } from '../../services/configs.service' ; import { Location } from '@angular/common' ; import { FormToastService } from '../../services/form-toast.service' ; import { EmailResendService } from '../../services/email-resend.service' ; see AnnouncementComponent @ Component ( { selector : 'm-emailConfirmation' , templateUrl : 'email-confirmation.component.html' , styleUrls : [ 'email-confirmation.component.ng.scss' ] , changeDetection : ChangeDetectionStrategy . OnPush , } ) export class EmailConfirmationComponent implements OnInit , OnDestroy { private readonly fromEmailConfirmation : number ; public sent : boolean = false ; public shouldShow : boolean = false ; public retryTimer$ : Observable < number > = this . emailResend . retryTimer$ ; public resendInProgress$ : Observable < boolean > = this . emailResend . inProgress$ ; protected userEmitter$ : Subscription ; constructor ( protected session , protected cd , protected location , protected toast , protected emailResend , configs ) { this . fromEmailConfirmation = configs . get ( 'from_email_confirmation' ) ; } ngOnInit ( ) { this . setShouldShow ( this . session . getLoggedInUser ( ) ) ; this . userEmitter$ = this . session . userEmitter . subscribe ( user => { this . sent = false ; this . setShouldShow ( user ) ; this . detectChanges ( ) ; } ) ; } ngOnDestroy ( ) { if ( this . userEmitter$ ) { this . userEmitter$ . unsubscribe ( ) ; } } param { Object } user setShouldShow ( user ) { this . shouldShow = ! ( this . location . path ( ) . indexOf ( '/onboarding' ) === 0 ) && ! this . fromEmailConfirmation && user && user . email_confirmed === false ; } /**
     * Uses the service to re-send the confirmation email
     */ async send ( ) { this . sent = true ; this . emailResend . send ( ) ; this . detectChanges ( ) ; } detectChanges ( ) { this . cd . markForCheck ( ) ; this . cd . detectChanges ( ) ; } }