This commit is contained in:
insanity 2017-07-04 18:26:48 +09:00
parent 2d1338e0a7
commit ed49b5ecdf

View File

@ -5,26 +5,26 @@ import AppContext from '@overflow/commons/context';
import Action from '@overflow/commons/redux/Action';
import Target from '../../api/model/Target';
import TargetService from '../../api/service/TargetService';
import * as RegistActions from '../action/regist';
import RegistPayload from '../payload/RegistPayload';
import TargetDiscoveryService from '../../api/service/TargetDiscoveryService';
import * as RegistDiscoveredTargetActions from '../action/regist_discovered_target';
import RegistDiscoveredTargetPayload from '../payload/RegistDiscoveredTargetPayload';
function* registDiscoveredTarget(action: Action<RegistPayload>): SagaIterator {
function* registDiscoveredTarget(action: Action<RegistDiscoveredTargetPayload>): SagaIterator {
try {
const {target} = action.payload;
const {hosts, probe} = action.payload;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
const retTarget = yield call(AppContext.getService<TargetService>().regist, target);
yield call(AppContext.getService<TargetDiscoveryService>().saveAllTarget, hosts, probe);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(RegistActions.requestSuccess(retTarget));
yield put(RegistDiscoveredTargetActions.requestSuccess());
} catch (e) {
yield put(RegistActions.requestFailure(e));
yield put(RegistDiscoveredTargetActions.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
@ -33,6 +33,6 @@ function* registDiscoveredTarget(action: Action<RegistPayload>): SagaIterator {
}
}
export function* watchRegist(): SagaIterator {
yield takeLatest(RegistActions.REQUEST, regist);
export function* watchRegistDiscoveredTarget(): SagaIterator {
yield takeLatest(RegistDiscoveredTargetActions.REQUEST, registDiscoveredTarget);
}