Skip to content

Commit c7f8ed1

Browse files
authored
Merge pull request #4519 from atmire/accessibility-settings-7_x
[Port dspace-7_x] Accessibility settings page SSR Fix
2 parents c07bc3c + c6ef246 commit c7f8ed1

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

src/app/info/accessibility-settings/accessibility-settings.component.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnDestroy, OnInit } from '@angular/core';
1+
import { Component, OnDestroy, OnInit, Optional } from '@angular/core';
22
import { AuthService } from '../../core/auth/auth.service';
33
import {
44
AccessibilitySetting,
@@ -8,7 +8,7 @@ import {
88
import { BehaviorSubject, distinctUntilChanged, map, Subscription, take } from 'rxjs';
99
import { NotificationsService } from '../../shared/notifications/notifications.service';
1010
import { TranslateService } from '@ngx-translate/core';
11-
import { isEmpty } from 'src/app/shared/empty.util';
11+
import { hasValue, isEmpty } from 'src/app/shared/empty.util';
1212
import { AlertType } from '../../shared/alert/alert-type';
1313
import { 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

Comments
 (0)