Update store on new challenge
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
e0e7329a99
commit
631f75e9f3
@ -61,6 +61,24 @@ class ShowClassic extends PureComponent {
|
|||||||
updateChallengeMeta(challengeMeta);
|
updateChallengeMeta(challengeMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
const { data: { challengeNode: { title: prevTitle } } } = prevProps;
|
||||||
|
const {
|
||||||
|
createFiles,
|
||||||
|
initTests,
|
||||||
|
updateChallengeMeta,
|
||||||
|
data: {
|
||||||
|
challengeNode: { files, title: currentTitle, fields: { tests } }
|
||||||
|
},
|
||||||
|
pathContext: { challengeMeta }
|
||||||
|
} = this.props;
|
||||||
|
if (prevTitle !== currentTitle) {
|
||||||
|
createFiles(files);
|
||||||
|
initTests(tests);
|
||||||
|
updateChallengeMeta(challengeMeta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
data: {
|
data: {
|
||||||
|
@ -16,7 +16,8 @@ import Spacer from '../../../../components/util/Spacer';
|
|||||||
import {
|
import {
|
||||||
consoleOutputSelector,
|
consoleOutputSelector,
|
||||||
challengeTestsSelector,
|
challengeTestsSelector,
|
||||||
executeChallenge
|
executeChallenge,
|
||||||
|
initConsole
|
||||||
} from '../../redux';
|
} from '../../redux';
|
||||||
import { descriptionRegex } from '../../../../../utils';
|
import { descriptionRegex } from '../../../../../utils';
|
||||||
|
|
||||||
@ -27,12 +28,13 @@ const mapStateToProps = createSelector(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch =>
|
const mapDispatchToProps = dispatch =>
|
||||||
bindActionCreators({ executeChallenge }, dispatch);
|
bindActionCreators({ executeChallenge, initConsole }, dispatch);
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
description: PropTypes.arrayOf(PropTypes.string),
|
description: PropTypes.arrayOf(PropTypes.string),
|
||||||
executeChallenge: PropTypes.func.isRequired,
|
executeChallenge: PropTypes.func.isRequired,
|
||||||
guideUrl: PropTypes.string,
|
guideUrl: PropTypes.string,
|
||||||
|
initConsole: PropTypes.func.isRequired,
|
||||||
output: PropTypes.string,
|
output: PropTypes.string,
|
||||||
tests: PropTypes.arrayOf(
|
tests: PropTypes.arrayOf(
|
||||||
PropTypes.shape({
|
PropTypes.shape({
|
||||||
@ -49,9 +51,14 @@ export class SidePanel extends PureComponent {
|
|||||||
this.bindTopDiv = this.bindTopDiv.bind(this);
|
this.bindTopDiv = this.bindTopDiv.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUpdate(nextProps) {
|
componentDidMount() {
|
||||||
const { title } = this.props;
|
this.props.initConsole('');
|
||||||
if (title !== nextProps.title) {
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
const { title, initConsole } = this.props;
|
||||||
|
if (title !== prevProps.title) {
|
||||||
|
initConsole('');
|
||||||
const node = ReactDom.findDOMNode(this.descriptionTop);
|
const node = ReactDom.findDOMNode(this.descriptionTop);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
node.scrollIntoView({ behavior: 'smooth' });
|
node.scrollIntoView({ behavior: 'smooth' });
|
||||||
|
Reference in New Issue
Block a user