Implement healthcheck service
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma
2020-07-22 20:31:12 +02:00
parent e525227865
commit d494a7c7d6
5 changed files with 103 additions and 74 deletions

View File

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