From 0674b0ac7cf39d0f259893d663a7b1c4c7be11e5 Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Mon, 27 Jan 2020 17:28:17 +0100 Subject: [PATCH] Close menu on navigation --- projects/common/src/fm/components/app/app.component.ts | 5 ++++- projects/common/src/fm/effects/app-common.effects.ts | 9 +-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/projects/common/src/fm/components/app/app.component.ts b/projects/common/src/fm/components/app/app.component.ts index b315b7b..f26e3cd 100644 --- a/projects/common/src/fm/components/app/app.component.ts +++ b/projects/common/src/fm/components/app/app.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, OnDestroy, Inject, ViewEncapsulation, RendererFactory2, PLATFORM_ID, ChangeDetectionStrategy, HostListener } from '@angular/core'; -import { Router, NavigationEnd, RouteConfigLoadStart, RouteConfigLoadEnd, ActivatedRoute, PRIMARY_OUTLET } from '@angular/router'; +import { Router, NavigationStart, NavigationEnd, RouteConfigLoadStart, RouteConfigLoadEnd, ActivatedRoute, PRIMARY_OUTLET } from '@angular/router'; import { Meta, Title, MetaDefinition } from '@angular/platform-browser';import { DOCUMENT } from "@angular/common"; import { Subscription , Observable } from 'rxjs'; import { Store, Action } from '@ngrx/store'; @@ -117,6 +117,9 @@ export class AppComponent implements OnInit, OnDestroy { if (event instanceof RouteConfigLoadEnd) { other.store.dispatch(new commonActions.EndRouteLoading()); } + if(event instanceof NavigationStart) { + other.store.dispatch(new commonActions.SetMenuVisible(false)); + } }); } diff --git a/projects/common/src/fm/effects/app-common.effects.ts b/projects/common/src/fm/effects/app-common.effects.ts index 63c2350..cc974dd 100644 --- a/projects/common/src/fm/effects/app-common.effects.ts +++ b/projects/common/src/fm/effects/app-common.effects.ts @@ -101,14 +101,7 @@ export class AppCommonEffects { } )); - @Effect() - closeMenuOnRouting$:Observable = this.actions$.pipe( - ofType(appCommonActions.STARTROUTELOADING), - switchMap((action) => { - return of(new appCommonActions.SetMenuVisible(false)); - } - )); - + @Effect({ dispatch: false }) fail$: Observable = this.actions$.pipe( ofType(appCommonActions.FAIL),