1- import { Injectable } from '@angular/core' ;
1+ import { Inject , Injectable , PLATFORM_ID } from '@angular/core' ;
22import { ActivatedRoute , ActivatedRouteSnapshot , Resolve , RouterStateSnapshot } from '@angular/router' ;
3- import { combineLatest , combineLatest as observableCombineLatest , Observable } from 'rxjs' ;
3+ import { combineLatest as observableCombineLatest , Observable , of } from 'rxjs' ;
44import { MenuID } from './shared/menu/menu-id.model' ;
55import { MenuState } from './shared/menu/menu-state.model' ;
66import { MenuItemType } from './shared/menu/menu-item-type.model' ;
@@ -52,11 +52,12 @@ import { environment } from '../environments/environment';
5252import { SectionDataService } from './core/layout/section-data.service' ;
5353import { Section } from './core/layout/models/section.model' ;
5454import { NOTIFICATIONS_RECITER_SUGGESTION_PATH } from './admin/admin-notifications/admin-notifications-routing-paths' ;
55+ import { isPlatformBrowser } from '@angular/common' ;
5556import { ConfigurationDataService } from './core/data/configuration-data.service' ;
5657import { ConfigurationProperty } from './core/shared/configuration-property.model' ;
5758
5859/**
59- * Creates all of the app's menus
60+ * Creates all the app's menus
6061 */
6162@Injectable ( {
6263 providedIn : 'root'
@@ -66,6 +67,7 @@ export class MenuResolver implements Resolve<boolean> {
6667 private activatedRouteLastChild : ActivatedRoute ;
6768
6869 constructor (
70+ @Inject ( PLATFORM_ID ) public platformId : any ,
6971 protected route : ActivatedRoute ,
7072 protected menuService : MenuService ,
7173 protected authorizationService : AuthorizationDataService ,
@@ -80,6 +82,9 @@ export class MenuResolver implements Resolve<boolean> {
8082 * Initialize all menus
8183 */
8284 resolve ( route : ActivatedRouteSnapshot , state : RouterStateSnapshot ) : Observable < boolean > {
85+ if ( ! isPlatformBrowser ( this . platformId ) ) {
86+ return of ( true ) ;
87+ }
8388 return observableCombineLatest ( [
8489 this . createPublicMenu$ ( ) ,
8590 this . createAdminMenu$ ( ) ,
@@ -544,7 +549,7 @@ export class MenuResolver implements Resolve<boolean> {
544549 ] ;
545550 menuList . forEach ( ( menuSection ) => this . menuService . addSection ( MenuID . ADMIN , menuSection ) ) ;
546551
547- combineLatest ( [
552+ observableCombineLatest ( [
548553 this . authorizationService . isAuthorized ( FeatureID . AdministratorOf ) ,
549554 this . authorizationService . isAuthorized ( FeatureID . IsCommunityAdmin ) ,
550555 this . authorizationService . isAuthorized ( FeatureID . IsCollectionAdmin ) ,
@@ -677,7 +682,7 @@ export class MenuResolver implements Resolve<boolean> {
677682 const menuList = [ ] ;
678683 menuList . forEach ( ( menuSection ) => this . menuService . addSection ( MenuID . ADMIN , menuSection ) ) ;
679684
680- combineLatest ( [
685+ observableCombineLatest ( [
681686 this . authorizationService . isAuthorized ( FeatureID . AdministratorOf ) ,
682687 this . authorizationService . isAuthorized ( FeatureID . IsCommunityAdmin ) ,
683688 this . authorizationService . isAuthorized ( FeatureID . IsCollectionAdmin ) ,
0 commit comments