1- import { Component , OnDestroy , OnInit } from '@angular/core' ;
1+ import { Component , OnDestroy , OnInit , Optional } from '@angular/core' ;
22import { AuthService } from '../../core/auth/auth.service' ;
33import {
44 AccessibilitySetting ,
88import { BehaviorSubject , distinctUntilChanged , map , Subscription , take } from 'rxjs' ;
99import { NotificationsService } from '../../shared/notifications/notifications.service' ;
1010import { TranslateService } from '@ngx-translate/core' ;
11- import { isEmpty } from 'src/app/shared/empty.util' ;
11+ import { hasValue , isEmpty } from 'src/app/shared/empty.util' ;
1212import { AlertType } from '../../shared/alert/alert-type' ;
1313import { KlaroService } from '../../shared/cookies/klaro.service' ;
1414
@@ -35,7 +35,7 @@ export class AccessibilitySettingsComponent implements OnInit, OnDestroy {
3535 protected settingsService : AccessibilitySettingsService ,
3636 protected notificationsService : NotificationsService ,
3737 protected translateService : TranslateService ,
38- protected klaroService : KlaroService ,
38+ @ Optional ( ) protected klaroService : KlaroService ,
3939 ) {
4040 }
4141
@@ -45,11 +45,19 @@ export class AccessibilitySettingsComponent implements OnInit, OnDestroy {
4545 this . subscriptions . push (
4646 this . authService . isAuthenticated ( ) . pipe ( distinctUntilChanged ( ) )
4747 . subscribe ( val => this . isAuthenticated . next ( val ) ) ,
48- this . klaroService . getSavedPreferences ( ) . pipe (
49- map ( preferences => preferences ?. accessibility === true ) ,
50- distinctUntilChanged ( ) ,
51- ) . subscribe ( val => this . cookieIsAccepted . next ( val ) ) ,
5248 ) ;
49+
50+ if ( hasValue ( this . klaroService ) ) {
51+ this . subscriptions . push (
52+ this . klaroService . getSavedPreferences ( ) . pipe (
53+ map ( preferences => preferences ?. accessibility === true ) ,
54+ distinctUntilChanged ( ) ,
55+ ) . subscribe ( val => this . cookieIsAccepted . next ( val ) )
56+ ) ;
57+ } else {
58+ this . cookieIsAccepted . next ( false ) ;
59+ }
60+
5361 }
5462
5563 ngOnDestroy ( ) {
0 commit comments