equal
deleted
inserted
replaced
1 import * as types from '../constants/actionTypes'; |
1 import * as types from '../constants/actionTypes'; |
2 import { all, call, fork, race, take, cancelled, put, select } from 'redux-saga/effects' |
2 import { all, call, fork, race, take, cancelled, put, select } from 'redux-saga/effects' |
3 import config from '../config'; |
3 import config from '../config'; |
4 import * as persistConstants from 'redux-persist/constants'; |
|
5 import jwt_decode from 'jwt-decode'; |
4 import jwt_decode from 'jwt-decode'; |
6 import moment from 'moment'; |
5 import moment from 'moment'; |
7 import { delay } from 'redux-saga'; |
6 import { delay } from 'redux-saga'; |
8 import { setOnlineStatus } from '../actions/networkActions'; |
7 import { setOnlineStatus } from '../actions/networkActions'; |
9 import { getToken } from '../selectors/authSelectors'; |
8 import { getToken } from '../selectors/authSelectors'; |
88 } |
87 } |
89 |
88 |
90 // Wait for successful response, then fire another request |
89 // Wait for successful response, then fire another request |
91 // Cancel polling if user logs out or log in |
90 // Cancel polling if user logs out or log in |
92 function* watchPollData(context) { |
91 function* watchPollData(context) { |
93 |
|
94 //wait for the state to be rehydrated |
|
95 yield take(persistConstants.REHYDRATE); |
|
96 |
|
97 while (true) { |
92 while (true) { |
98 yield race({ |
93 yield race({ |
99 poll: all([call(pollData, context), call(callDelay, context)]), |
94 poll: all([call(pollData, context), call(callDelay, context)]), |
100 logout: take(types.AUTH_LOGOUT), |
95 logout: take(types.AUTH_LOGOUT), |
101 login: take(types.AUTH_LOGIN_SUCCESS) |
96 login: take(types.AUTH_LOGIN_SUCCESS) |