author Ben Hayward
 *  desc import { Injectable } from '@angular/core' ; import { BehaviorSubject , Subscription } from 'rxjs' ; import { Session } from '../../services/session' ; import { MindsUser } from '../../interfaces/entities' ; import { ConfigsService } from './configs.service' ; @ Injectable ( { providedIn : 'root' , } ) export class UserAvatarService { private user : MindsUser ; public src$ : BehaviorSubject < string > = new BehaviorSubject < string > ( '' ) ; public loggedIn$ : Subscription ; constructor ( public session , private configs ) { this . init ( ) ; if ( this . session . loggedinEmitter ) { this . loggedIn$ = this . session . loggedinEmitter . subscribe ( is => { if ( is ) { this . src$ . next ( this . getSrc ( ) ) ; } } ) ; } } /**
     * Sets the current user and avatar src.
     */ public init ( ) { this . user = this . session . getLoggedInUser ( ) ; this . src$ . next ( this . getSrc ( ) ) ; } /**
     * Gets the Src string using the global minds object and the held user object.
     */ public getSrc ( ) { return `${ this . configs . get ( 'cdn_url' ) }icon/${ this . user . guid }/large/${ this . user . icontime }` ; } }