mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
header, isNavBarCollapsed observable: filter out undefined state that can occur when using AoT compilation
This commit is contained in:
@@ -37,6 +37,13 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
translate.setDefaultLang('en');
|
||||
// the lang to use, if the lang isn't available, it will use the current loader to get them
|
||||
translate.use('en');
|
||||
|
||||
this.onResize({
|
||||
target: {
|
||||
innerWidth: 800,
|
||||
innerHeight: 600
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { EffectsModule } from "@ngrx/effects";
|
||||
import { HeaderEffects } from "./header/header.effects";
|
||||
|
||||
export default [
|
||||
export const effects = [
|
||||
EffectsModule.run(HeaderEffects)
|
||||
];
|
||||
|
@@ -11,8 +11,8 @@ import { StoreModule } from "@ngrx/store";
|
||||
import { RouterStoreModule } from "@ngrx/router-store";
|
||||
import { StoreDevtoolsModule } from "@ngrx/store-devtools";
|
||||
|
||||
import reducers from './app.reducers';
|
||||
import effects from './app.effects';
|
||||
import { reducers } from './app.reducers';
|
||||
import { effects } from './app.effects';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { headerReducer } from './header/header.reducer';
|
||||
import { hostWindowReducer } from "./shared/host-window.reducer";
|
||||
|
||||
export default {
|
||||
export const reducers = {
|
||||
headerReducer,
|
||||
hostWindowReducer
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ import { Store } from "@ngrx/store";
|
||||
import { HeaderState } from "./header.reducer";
|
||||
import { HeaderActions } from "./header.actions";
|
||||
import { Observable } from "rxjs";
|
||||
import 'rxjs/add/operator/filter';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-header',
|
||||
@@ -19,6 +20,9 @@ export class HeaderComponent implements OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.isNavBarCollapsed = this.store.select('headerReducer')
|
||||
//ensure that state is not null, can happen when using AoT compilation
|
||||
.filter((state: HeaderState) => state !== null && state !== undefined)
|
||||
//unwrap navCollapsed
|
||||
.map(({ navCollapsed }: HeaderState) => navCollapsed);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user