2019-12-02 15:48:53 +03:00
|
|
|
import { put, select, takeEvery, delay } from 'redux-saga/effects';
|
|
|
|
|
|
|
|
import {
|
|
|
|
openDonationModal,
|
2019-12-06 08:43:23 +03:00
|
|
|
preventDonationRequests,
|
|
|
|
shouldRequestDonationSelector
|
2019-12-02 15:48:53 +03:00
|
|
|
} from './';
|
|
|
|
|
|
|
|
function* showDonateModalSaga() {
|
|
|
|
let shouldRequestDonation = yield select(shouldRequestDonationSelector);
|
|
|
|
if (shouldRequestDonation) {
|
|
|
|
yield delay(200);
|
|
|
|
yield put(openDonationModal());
|
|
|
|
yield put(preventDonationRequests());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createDonationSaga(types) {
|
|
|
|
return [takeEvery(types.tryToShowDonationModal, showDonateModalSaga)];
|
|
|
|
}
|