@ -4,12 +4,13 @@
import { AfterViewInit , Component , computed , createNgModule , ElementRef , Inject , Injector , OnDestroy , OnInit , Renderer2 , signal , ViewChild , ViewContainerRef , inject } from '@angular/core' ;
import { combineLatest , Observable , skip , startWith , Subject } from 'rxjs' ;
import { select , Store } from '@ngrx/store' ;
import { toSignal } from '@angular/core/rxjs-interop' ;
import { debounceTime , distinctUntilChanged , map , share , take , takeUntil } from 'rxjs/operators' ;
import { BreakpointObserver , BreakpointState } from '@angular/cdk/layout' ;
import { PageComponent } from '@shared/components/page.component' ;
import { AppState } from '@core/core.state' ;
import { getCurrentAuthState , selectUserSettingsProperty } from '@core/auth/auth.selectors' ;
import { getCurrentAuthState , selectAuth , select UserSettingsProperty } from '@core/auth/auth.selectors' ;
import { MediaBreakpoints } from '@shared/models/constants' ;
import screenfull from 'screenfull' ;
import { MatSidenav } from '@angular/material/sidenav' ;
@ -74,17 +75,27 @@ export class HomeComponent extends PageComponent implements AfterViewInit, OnIni
private tourService = inject ( TourService ) ;
readonly aiAvailable = this . tourService . aiAvailable ( ) ;
readonly aiAvailable = toSignal ( inject ( Store < AppState > ) . select ( selectAuth ) . pipe (
map ( ( ) = > this . tourService . aiAvailable ( ) ) ,
distinctUntilChanged ( )
) , { initialValue : this.tourService.aiAvailable ( ) } ) ;
readonly aiPanelLoaded = signal ( false ) ;
private injector = inject ( Injector ) ;
@ViewChild ( 'aiPanelHost' , { read : ViewContainerRef } ) set aiPanelHost ( host : ViewContainerRef ) {
if ( host && ! this . aiPanelLoaded ( ) ) {
private panelHost : ViewContainerRef | undefined ;
@ViewChild ( 'aiPanelHost' , { read : ViewContainerRef } ) set aiPanelHost ( host : ViewContainerRef | undefined ) {
this . panelHost = host ;
if ( ! host ) {
this . aiPanelLoaded . set ( false ) ;
return ;
}
if ( ! this . aiPanelLoaded ( ) ) {
Promise . all ( [ import ( '@home/components/ai/ai.module' ) , import ( '@home/components/ai/ai-assistant-panel.component' ) ] )
. then ( ( [ { AiModule } , { AiAssistantPanelComponent } ] ) = > {
if ( ! this . aiPanelLoaded ( ) ) {
if ( this . panelHost === host && ! this . aiPanelLoaded ( ) ) {
host . createComponent ( AiAssistantPanelComponent , { ngModuleRef : createNgModule ( AiModule , this . injector ) } ) ;
this . aiPanelLoaded . set ( true ) ;
}