fix: move donation modal from end of challenge to before a challenge.
This commit is contained in:
committed by
Stuart Taylor
parent
108884cbba
commit
e4affac93a
@ -23,8 +23,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
userSelector,
|
userSelector,
|
||||||
isSignedInSelector,
|
isSignedInSelector,
|
||||||
openDonationModal,
|
|
||||||
showDonationSelector,
|
|
||||||
submitComplete,
|
submitComplete,
|
||||||
updateComplete,
|
updateComplete,
|
||||||
updateFailed
|
updateFailed
|
||||||
@ -126,19 +124,13 @@ const submitters = {
|
|||||||
'project.backEnd': submitProject
|
'project.backEnd': submitProject
|
||||||
};
|
};
|
||||||
|
|
||||||
function shouldShowDonate(state) {
|
|
||||||
return showDonationSelector(state) ? of(openDonationModal()) : empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function completionEpic(action$, state$) {
|
export default function completionEpic(action$, state$) {
|
||||||
return action$.pipe(
|
return action$.pipe(
|
||||||
ofType(types.submitChallenge),
|
ofType(types.submitChallenge),
|
||||||
switchMap(({ type }) => {
|
switchMap(({ type }) => {
|
||||||
const state = state$.value;
|
const state = state$.value;
|
||||||
const meta = challengeMetaSelector(state);
|
const meta = challengeMetaSelector(state);
|
||||||
const { isDonating } = userSelector(state);
|
|
||||||
const { nextChallengePath, introPath, challengeType } = meta;
|
const { nextChallengePath, introPath, challengeType } = meta;
|
||||||
const showDonate = isDonating ? empty() : shouldShowDonate(state);
|
|
||||||
const closeChallengeModal = of(closeModal('completion'));
|
const closeChallengeModal = of(closeModal('completion'));
|
||||||
let submitter = () => of({ type: 'no-user-signed-in' });
|
let submitter = () => of({ type: 'no-user-signed-in' });
|
||||||
if (
|
if (
|
||||||
@ -157,7 +149,6 @@ export default function completionEpic(action$, state$) {
|
|||||||
return submitter(type, state).pipe(
|
return submitter(type, state).pipe(
|
||||||
tap(() => navigate(introPath ? introPath : nextChallengePath)),
|
tap(() => navigate(introPath ? introPath : nextChallengePath)),
|
||||||
concat(closeChallengeModal),
|
concat(closeChallengeModal),
|
||||||
concat(showDonate),
|
|
||||||
filter(Boolean)
|
filter(Boolean)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
@ -3,8 +3,11 @@ import { put, select, call, takeEvery } from 'redux-saga/effects';
|
|||||||
import {
|
import {
|
||||||
isSignedInSelector,
|
isSignedInSelector,
|
||||||
currentChallengeIdSelector,
|
currentChallengeIdSelector,
|
||||||
|
openDonationModal,
|
||||||
|
showDonationSelector,
|
||||||
updateComplete,
|
updateComplete,
|
||||||
updateFailed
|
updateFailed,
|
||||||
|
userSelector
|
||||||
} from '../../../redux';
|
} from '../../../redux';
|
||||||
|
|
||||||
import { post } from '../../../utils/ajax';
|
import { post } from '../../../utils/ajax';
|
||||||
@ -35,9 +38,18 @@ function* updateSuccessMessageSaga() {
|
|||||||
yield put(updateSuccessMessage(randomCompliment()));
|
yield put(updateSuccessMessage(randomCompliment()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function* showDonateModalSaga() {
|
||||||
|
let { isDonating } = yield select(userSelector);
|
||||||
|
let shouldShowDonate = yield select(showDonationSelector);
|
||||||
|
if (!isDonating && shouldShowDonate) {
|
||||||
|
yield put(openDonationModal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function createCurrentChallengeSaga(types) {
|
export function createCurrentChallengeSaga(types) {
|
||||||
return [
|
return [
|
||||||
takeEvery(types.challengeMounted, currentChallengeSaga),
|
takeEvery(types.challengeMounted, currentChallengeSaga),
|
||||||
takeEvery(types.challengeMounted, updateSuccessMessageSaga)
|
takeEvery(types.challengeMounted, updateSuccessMessageSaga),
|
||||||
|
takeEvery(types.challengeMounted, showDonateModalSaga)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user