2019-09-18 15:02:21 +09:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
|
|
|
import { Actions, ofType, createEffect } from '@ngrx/effects';
|
|
|
|
|
|
|
|
import { of } from 'rxjs';
|
|
|
|
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
|
|
|
|
|
|
|
import { PublicApiService } from '@ucap-webmessenger/api-public';
|
|
|
|
import { StatusCode } from '@ucap-webmessenger/api';
|
2019-09-19 10:40:16 +09:00
|
|
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
|
|
|
|
2019-09-26 11:11:22 +09:00
|
|
|
import { NGXLogger } from 'ngx-logger';
|
|
|
|
|
2019-10-04 10:19:55 +09:00
|
|
|
import {
|
|
|
|
versionInfo2,
|
|
|
|
versionInfo2Success,
|
|
|
|
versionInfo2Failure
|
|
|
|
} from './actions';
|
2019-09-18 15:02:21 +09:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class Effects {
|
2019-10-04 10:19:55 +09:00
|
|
|
versionInfo2$ = createEffect(() =>
|
2019-09-18 15:02:21 +09:00
|
|
|
this.actions$.pipe(
|
2019-10-04 10:19:55 +09:00
|
|
|
ofType(versionInfo2),
|
2019-09-18 15:02:21 +09:00
|
|
|
map(action => action),
|
|
|
|
exhaustMap(req =>
|
2019-09-19 10:40:16 +09:00
|
|
|
this.publicApiService.versionInfo2(req).pipe(
|
2019-09-18 15:02:21 +09:00
|
|
|
map(res => {
|
|
|
|
if (res.statusCode === StatusCode.Success) {
|
2019-10-04 10:19:55 +09:00
|
|
|
return versionInfo2Success({ res });
|
2019-09-18 15:02:21 +09:00
|
|
|
} else {
|
2019-10-04 10:19:55 +09:00
|
|
|
return versionInfo2Failure({ error: 'Failed' });
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
}),
|
2019-10-04 10:19:55 +09:00
|
|
|
catchError(error => of(versionInfo2Failure({ error })))
|
2019-09-18 15:02:21 +09:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private actions$: Actions,
|
|
|
|
private publicApiService: PublicApiService,
|
2019-09-19 10:40:16 +09:00
|
|
|
private sessionStorageService: SessionStorageService,
|
2019-09-26 11:11:22 +09:00
|
|
|
private router: Router,
|
|
|
|
private logger: NGXLogger
|
2019-09-18 15:02:21 +09:00
|
|
|
) {}
|
|
|
|
}
|