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

View File

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

View File

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