diff --git a/common/sagas/swap/rates.ts b/common/sagas/swap/rates.ts index 1f31720e..640508b9 100644 --- a/common/sagas/swap/rates.ts +++ b/common/sagas/swap/rates.ts @@ -1,9 +1,12 @@ import { showNotification } from 'actions/notifications'; import { loadBityRatesSucceededSwap } from 'actions/swap'; +import { TypeKeys } from 'actions/swap/constants'; import { getAllRates } from 'api/bity'; import { delay, SagaIterator } from 'redux-saga'; import { call, cancel, fork, put, take, takeLatest } from 'redux-saga/effects'; +const POLLING_CYCLE = 30000; + export function* loadBityRates(): SagaIterator { while (true) { try { @@ -12,18 +15,18 @@ export function* loadBityRates(): SagaIterator { } catch (error) { yield put(showNotification('danger', error.message)); } - yield call(delay, 5000); + yield call(delay, POLLING_CYCLE); } } // Fork our recurring API call, watch for the need to cancel. function* handleBityRates(): SagaIterator { const loadBityRatesTask = yield fork(loadBityRates); - yield take('SWAP_STOP_LOAD_BITY_RATES'); + yield take(TypeKeys.SWAP_STOP_LOAD_BITY_RATES); yield cancel(loadBityRatesTask); } // Watch for latest SWAP_LOAD_BITY_RATES_REQUESTED action. export function* getBityRatesSaga(): SagaIterator { - yield takeLatest('SWAP_LOAD_BITY_RATES_REQUESTED', handleBityRates); + yield takeLatest(TypeKeys.SWAP_LOAD_BITY_RATES_REQUESTED, handleBityRates); }