noop catchError (#675)

This commit is contained in:
Cilibiu Bogdan
2018-09-29 13:30:36 +03:00
committed by Denys Vuika
parent 93e6489881
commit 3ca68f751b

View File

@@ -26,13 +26,12 @@
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Injectable } from '@angular/core';
import { DiscoveryEntry } from 'alfresco-js-api';
import { map, switchMap, catchError } from 'rxjs/operators';
import { map, mergeMap, catchError } from 'rxjs/operators';
import { of } from 'rxjs';
import {
GET_REPOSITORY_STATUS,
GetRepositoryStatusAction
} from '../actions/repository.actions';
import { Router } from '@angular/router';
import { ContentApiService } from '../../services/content-api.service';
import { SetRepositoryStatusAction } from '../actions';
@@ -40,28 +39,21 @@ import { SetRepositoryStatusAction } from '../actions';
export class RepositoryEffects {
constructor(
private actions$: Actions,
private router: Router,
private contentApi: ContentApiService
) {}
@Effect()
getRepositoryStatus$ = this.actions$.pipe(
ofType<GetRepositoryStatusAction>(GET_REPOSITORY_STATUS),
switchMap(() => {
mergeMap(() => {
return this.contentApi.getRepositoryInformation().pipe(
map(
(response: DiscoveryEntry) =>
new SetRepositoryStatusAction(response.entry.repository.status)
),
catchError(error => {
this.redirectToLogin();
return of(error);
})
// needs proper error handling
catchError(() => of({ type: 'noop' }))
);
})
);
private redirectToLogin() {
this.router.navigate(['login']);
}
}