Only on change
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma 2020-07-22 21:16:38 +02:00
parent d494a7c7d6
commit e057e463bd
2 changed files with 5 additions and 7 deletions

View File

@ -2,6 +2,7 @@ import { Component, OnInit, OnDestroy, Inject, ViewEncapsulation, RendererFactor
import { Router, NavigationStart, 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 { Meta, Title, MetaDefinition } from '@angular/platform-browser';import { DOCUMENT } from "@angular/common";
import { Subscription , Observable } from 'rxjs'; import { Subscription , Observable } from 'rxjs';
import { distinctUntilChanged} from 'rxjs/operators';
import { Store, Action } from '@ngrx/store'; import { Store, Action } from '@ngrx/store';
import { IUser } from '../../models/user'; import { IUser } from '../../models/user';
@ -51,11 +52,11 @@ export class AppComponent implements OnInit, OnDestroy {
) { ) {
//check health every 30 seconds //check health every 30 seconds
this.healthCheckService.check(30000).subscribe((online) => { this.healthCheckService.check(30000).pipe(distinctUntilChanged()).subscribe((online) => {
if(online) { if(online) {
this.store.dispatch(new commonActions.Online()); this.store.dispatch(new commonActions.Online());
} else { } else {
this.store.dispatch(new commonActions.Offline()); this.store.dispatch(new commonActions.Offline());
} }
}); });
} }

View File

@ -165,9 +165,7 @@ export class AppCommonEffects {
@Effect({ dispatch: false }) @Effect({ dispatch: false })
online$: Observable<Action> = this.actions$.pipe( online$: Observable<Action> = this.actions$.pipe(
ofType(appCommonActions.ONLINE), ofType(appCommonActions.ONLINE),
withLatestFrom(this.store$.select(appCommonReducers.SelectGetIsOnline)), switchMap((action) => {
switchMap(([action,isOnline]) => {
if(!isOnline) {
console.debug("Online: Check token"); console.debug("Online: Check token");
if(!this.oauthService$.hasValidAccessToken()) { if(!this.oauthService$.hasValidAccessToken()) {
console.debug("No valid token, try to refresh"); console.debug("No valid token, try to refresh");
@ -177,7 +175,6 @@ export class AppCommonEffects {
this.store$.dispatch(new appCommonActions.InitUser()); this.store$.dispatch(new appCommonActions.InitUser());
}); });
} }
}
} }
return of(undefined); return of(undefined);
})); }));