fix(client): update success message for all challenges

This commit is contained in:
Valeriy S
2019-02-06 14:32:36 +03:00
committed by Stuart Taylor
parent f6fa754906
commit 2981d776c7
3 changed files with 14 additions and 22 deletions

View File

@ -21,7 +21,6 @@ import MobileLayout from './MobileLayout';
import DesktopLayout from './DesktopLayout';
import ToolPanel from '../components/Tool-Panel';
import { randomCompliment } from '../utils/get-words';
import { createGuideUrl } from '../utils';
import { challengeTypes } from '../../../../utils/challengeTypes';
import { ChallengeNode } from '../../../redux/propTypes';
@ -33,7 +32,6 @@ import {
initTests,
updateChallengeMeta,
challengeMounted,
updateSuccessMessage,
consoleOutputSelector
} from '../redux';
@ -52,8 +50,7 @@ const mapDispatchToProps = dispatch =>
createFiles,
initTests,
updateChallengeMeta,
challengeMounted,
updateSuccessMessage
challengeMounted
},
dispatch
);
@ -80,8 +77,7 @@ const propTypes = {
testString: PropTypes.string
})
),
updateChallengeMeta: PropTypes.func.isRequired,
updateSuccessMessage: PropTypes.func.isRequired
updateChallengeMeta: PropTypes.func.isRequired
};
const MAX_MOBILE_WIDTH = 767;
@ -113,7 +109,6 @@ class ShowClassic extends Component {
createFiles,
initTests,
updateChallengeMeta,
updateSuccessMessage,
data: {
challengeNode: {
files,
@ -127,7 +122,6 @@ class ShowClassic extends Component {
createFiles(files);
initTests(tests);
updateChallengeMeta({ ...challengeMeta, title, challengeType });
updateSuccessMessage(randomCompliment());
challengeMounted(challengeMeta.id);
}
@ -142,7 +136,6 @@ class ShowClassic extends Component {
createFiles,
initTests,
updateChallengeMeta,
updateSuccessMessage,
data: {
challengeNode: {
files,
@ -154,7 +147,6 @@ class ShowClassic extends Component {
pageContext: { challengeMeta }
} = this.props;
if (prevTitle !== currentTitle) {
updateSuccessMessage(randomCompliment());
createFiles(files);
initTests(tests);
updateChallengeMeta({

View File

@ -5,12 +5,10 @@ import { bindActionCreators } from 'redux';
import { graphql } from 'gatsby';
import Helmet from 'react-helmet';
import { randomCompliment } from '../utils/get-words';
import { ChallengeNode } from '../../../redux/propTypes';
import {
challengeMounted,
updateChallengeMeta,
updateSuccessMessage,
openModal,
updateProjectFormValues
} from '../redux';
@ -34,7 +32,6 @@ const mapDispatchToProps = dispatch =>
updateChallengeMeta,
challengeMounted,
updateProjectFormValues,
updateSuccessMessage,
openCompletionModal: () => openModal('completion')
},
dispatch
@ -50,8 +47,7 @@ const propTypes = {
challengeMeta: PropTypes.object
}),
updateChallengeMeta: PropTypes.func.isRequired,
updateProjectFormValues: PropTypes.func.isRequired,
updateSuccessMessage: PropTypes.func.isRequired
updateProjectFormValues: PropTypes.func.isRequired
};
export class Project extends Component {
@ -62,10 +58,8 @@ export class Project extends Component {
challengeNode: { title, challengeType }
},
pageContext: { challengeMeta },
updateChallengeMeta,
updateSuccessMessage
updateChallengeMeta
} = this.props;
updateSuccessMessage(randomCompliment());
updateChallengeMeta({ ...challengeMeta, title, challengeType });
challengeMounted(challengeMeta.id);
}
@ -82,10 +76,8 @@ export class Project extends Component {
challengeNode: { title: currentTitle, challengeType }
},
pageContext: { challengeMeta },
updateChallengeMeta,
updateSuccessMessage
updateChallengeMeta
} = this.props;
updateSuccessMessage(randomCompliment());
if (prevTitle !== currentTitle) {
updateChallengeMeta({
...challengeMeta,

View File

@ -9,6 +9,9 @@ import {
import { post } from '../../../utils/ajax';
import { randomCompliment } from '../utils/get-words';
import { updateSuccessMessage } from './';
function* currentChallengeSaga({ payload }) {
const isSignedIn = yield select(isSignedInSelector);
const currentChallengeId = yield select(currentChallengeIdSelector);
@ -28,8 +31,13 @@ function* currentChallengeSaga({ payload }) {
}
}
function* updateSuccessMessageSaga() {
yield put(updateSuccessMessage(randomCompliment()));
}
export function createCurrentChallengeSaga(types) {
return [
takeEvery(types.challengeMounted, currentChallengeSaga)
takeEvery(types.challengeMounted, currentChallengeSaga),
takeEvery(types.challengeMounted, updateSuccessMessageSaga)
];
}