import { Component , OnInit } from '@angular/core' ; import { Router } from '@angular/router' ; import { AuthModalService } from '../../../modules/auth/modal/auth-modal.service' ; import { GuestModeExperimentService } from '../../../modules/experiments/sub-services/guest-mode-experiment.service' ; import { Session } from '../../../services/session' ; import { SessionsStorageService } from '../../../services/session-storage.service' ; import { ConfigsService } from '../../services/configs.service' ; /**
 * Join banner, full width and fixed to bottom of page.
 */ @ Component ( { selector : 'm-joinBanner' , templateUrl : './join-banner.component.html' , styleUrls : [ './join-banner.component.ng.scss' ] , } ) export class JoinBannerComponent implements OnInit { public readonly cdnAssetsUrl : string = '' ; public dismissed = true ; constructor ( private session , private sessionStorage , private authModal , private guestModeExperiment , private router , configs ) { this . cdnAssetsUrl = configs . get ( 'cdn_assets_url' ) ; } ngOnInit ( ) { this . dismissed = ! ! this . sessionStorage . get ( 'dismissed_join_banner' ) ; } returns { boolean } public shouldShow ( ) { return ( this . guestModeExperiment . isActive ( ) && ! this . session . getLoggedInUser ( ) && ! this . dismissed ) ; } returns { void } public dismiss ( ) { this . dismissed = true ; this . sessionStorage . set ( 'dismissed_join_banner' , true ) ; } returns { Promise < void > } public async join ( ) { try { await this . authModal . open ( ) ; if ( this . router . url === '/' || this . router . url === '/about' ) { this . router . navigate ( [ '/newsfeed/subscriptions/latest' ] ) ; } } catch ( e ) { if ( e === 'DismissedModalException' ) { return ; } console . error ( e ) ; } } }