mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34: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');
|
translate.setDefaultLang('en');
|
||||||
// the lang to use, if the lang isn't available, it will use the current loader to get them
|
// the lang to use, if the lang isn't available, it will use the current loader to get them
|
||||||
translate.use('en');
|
translate.use('en');
|
||||||
|
|
||||||
|
this.onResize({
|
||||||
|
target: {
|
||||||
|
innerWidth: 800,
|
||||||
|
innerHeight: 600
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { EffectsModule } from "@ngrx/effects";
|
import { EffectsModule } from "@ngrx/effects";
|
||||||
import { HeaderEffects } from "./header/header.effects";
|
import { HeaderEffects } from "./header/header.effects";
|
||||||
|
|
||||||
export default [
|
export const effects = [
|
||||||
EffectsModule.run(HeaderEffects)
|
EffectsModule.run(HeaderEffects)
|
||||||
];
|
];
|
||||||
|
@@ -11,8 +11,8 @@ import { StoreModule } from "@ngrx/store";
|
|||||||
import { RouterStoreModule } from "@ngrx/router-store";
|
import { RouterStoreModule } from "@ngrx/router-store";
|
||||||
import { StoreDevtoolsModule } from "@ngrx/store-devtools";
|
import { StoreDevtoolsModule } from "@ngrx/store-devtools";
|
||||||
|
|
||||||
import reducers from './app.reducers';
|
import { reducers } from './app.reducers';
|
||||||
import effects from './app.effects';
|
import { effects } from './app.effects';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { headerReducer } from './header/header.reducer';
|
import { headerReducer } from './header/header.reducer';
|
||||||
import { hostWindowReducer } from "./shared/host-window.reducer";
|
import { hostWindowReducer } from "./shared/host-window.reducer";
|
||||||
|
|
||||||
export default {
|
export const reducers = {
|
||||||
headerReducer,
|
headerReducer,
|
||||||
hostWindowReducer
|
hostWindowReducer
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ import { Store } from "@ngrx/store";
|
|||||||
import { HeaderState } from "./header.reducer";
|
import { HeaderState } from "./header.reducer";
|
||||||
import { HeaderActions } from "./header.actions";
|
import { HeaderActions } from "./header.actions";
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
|
import 'rxjs/add/operator/filter';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-header',
|
selector: 'ds-header',
|
||||||
@@ -19,6 +20,9 @@ export class HeaderComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.isNavBarCollapsed = this.store.select('headerReducer')
|
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);
|
.map(({ navCollapsed }: HeaderState) => navCollapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user