[FIX] Change rooms request's race cancellation condition (#987)
* [FIX] Add Inactive state to rooms request's race cancellation * Changed rooms request's cancellation rules
This commit is contained in:
parent
5f259e552b
commit
1ba62f16ff
|
@ -1,7 +1,8 @@
|
||||||
|
import { delay } from 'redux-saga';
|
||||||
import {
|
import {
|
||||||
put, select, race, take, fork, cancel, takeLatest
|
put, select, race, take, fork, cancel, takeLatest
|
||||||
} from 'redux-saga/effects';
|
} from 'redux-saga/effects';
|
||||||
import { BACKGROUND } from 'redux-enhancer-react-native-appstate';
|
import { BACKGROUND, INACTIVE } from 'redux-enhancer-react-native-appstate';
|
||||||
|
|
||||||
import * as types from '../actions/actionsTypes';
|
import * as types from '../actions/actionsTypes';
|
||||||
import { roomsSuccess, roomsFailure } from '../actions/rooms';
|
import { roomsSuccess, roomsFailure } from '../actions/rooms';
|
||||||
|
@ -61,13 +62,20 @@ const root = function* root() {
|
||||||
yield takeLatest(types.LOGOUT, handleLogout);
|
yield takeLatest(types.LOGOUT, handleLogout);
|
||||||
while (true) {
|
while (true) {
|
||||||
const params = yield take(types.ROOMS.REQUEST);
|
const params = yield take(types.ROOMS.REQUEST);
|
||||||
const roomsRequestTask = yield fork(handleRoomsRequest, params);
|
const isAuthenticated = yield select(state => state.login.isAuthenticated);
|
||||||
yield race({
|
if (isAuthenticated) {
|
||||||
serverReq: take(types.SERVER.SELECT_REQUEST),
|
const roomsRequestTask = yield fork(handleRoomsRequest, params);
|
||||||
background: take(BACKGROUND),
|
yield race({
|
||||||
logout: take(types.LOGOUT)
|
roomsSuccess: take(types.ROOMS.SUCCESS),
|
||||||
});
|
roomsFailure: take(types.ROOMS.FAILURE),
|
||||||
yield cancel(roomsRequestTask);
|
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;
|
export default root;
|
||||||
|
|
Loading…
Reference in New Issue