Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
const endDirectLine = yield runAsyncEffectUntilDisconnect(
{
type: CONNECT,
meta,
payload: { directLine }
},
() => call(connectSaga, directLine)
);
try {
for (;;) {
// We are waiting for connection status change or disconnect action.
const { updateConnectionStatusAction: { payload: { connectionStatus } = {} } = {} } = yield race({
_: take(DISCONNECT),
updateConnectionStatusAction: take(UPDATE_CONNECTION_STATUS)
});
// If it is not disconnect action, connectionStatus will not be undefined.
if (connectionStatus === CONNECTING) {
// If DirectLineJS changed connectionStatus to CONNECTING, we will treat it as reconnect status.
yield runAsyncEffectUntilDisconnect(
{
type: RECONNECT,
meta,
payload: { directLine }
},
() => call(reconnectSaga)
);
} else if (connectionStatus !== ONLINE) {
if (typeof connectionStatus !== 'undefined') {
// We need to kill the connection because DirectLineJS want to close it.
export function* watchUpdateFormDataSaga(): SagaIterator {
const requestChan = yield actionChannel(FormDataActionTypes.UPDATE_FORM_DATA);
while (true) {
const value = yield take(requestChan);
yield call(updateFormDataSaga, value);
}
}
)
let res = yield api.leads.getMyLeads({
page,
limit,
sortBy,
category,
})
if (res.error) {
yield put(actions.leads.fetchError("MY_LEADS"))
} else {
yield put(actions.leads.fetchSuccess("MY_LEADS", res))
}
yield take([
types.MY_LEADS_FETCH_LEADS,
types.CHECKOUT_BUY_SUCCESS,
types.MY_LEADS_MOVE_TO_SELL_SUCCESS,
types.LOGIN_FINISH,
types.LOGGED_OUT,
])
}
}
export function* loggedInActions() {
do {
yield take(LOGIN_SUCCESS);
const task = yield fork(function*() {
yield all([
takeEvery(FIRE_PERSON, function*(action) {
yield call(firePerson, action.payload);
}),
takeEvery(HIRE_PERSON, function*(action) {
yield call(hirePerson, action.payload);
})
]);
});
yield take(LOGOUT);
task.cancel();
} while (true);
}
export function* flow() {
while (true) {
yield take(LOGIN)
yield put({
type: SET_GOLEM_STATUS,
payload: {
message: 'Starting Golem'
}
})
const {connection} = yield call(connect)
const task = yield fork(handleIO, connection)
let action = yield take(LOGOUT)
yield cancel(task)
}
}
const root = function* root() {
while (true) {
const params = yield take(types.ROOMS.REQUEST);
const isAuthenticated = yield select(state => state.login.isAuthenticated);
if (isAuthenticated) {
const roomsRequestTask = yield fork(handleRoomsRequest, params);
yield race({
roomsSuccess: take(types.ROOMS.SUCCESS),
roomsFailure: take(types.ROOMS.FAILURE),
serverReq: take(types.SERVER.SELECT_REQUEST),
background: take(BACKGROUND),
inactive: take(INACTIVE),
logout: take(types.LOGOUT),
timeout: delay(30000)
});
yield cancel(roomsRequestTask);
}
}
};
export default root;
function* fetchAttachmentsConcat({ payload: { params, concat } }) {
const url = yield call(getAttachmentURL);
yield put(concatFetchDataAction(ATTACHMENTS_NAMESPACE, concat)(url, { params }));
yield take(createFetchPredicate(ATTACHMENTS_NAMESPACE));
}
export function* getCommentsFlow() {
while (true) {
let request = yield take(frontActionTypes.GET_COMMENTS);
var { question_id } = request;
let response = yield call(getComments, question_id);
if (response && response.code === 0) {
yield put({
type: IndexActionTypes.SET_MESSAGE,
msgContent: "post comment success",
msgType: 1
});
yield put({
type: frontActionTypes.RESPONSE_COMMENTS,
comments: response.comments
});
}
}
}