Fix transitioning between hikes resets questions
This commit is contained in:
@ -10,7 +10,7 @@ const initValue = {
|
|||||||
hikes: [],
|
hikes: [],
|
||||||
// lecture state
|
// lecture state
|
||||||
currentHike: {},
|
currentHike: {},
|
||||||
showQuestion: false
|
showQuestions: false
|
||||||
},
|
},
|
||||||
jobsApp: {
|
jobsApp: {
|
||||||
showModal: false
|
showModal: false
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
|
import { contain } from 'thundercats-react';
|
||||||
import {
|
import {
|
||||||
Col,
|
Col,
|
||||||
Panel,
|
Panel,
|
||||||
@ -8,14 +9,29 @@ import {
|
|||||||
import Lecture from './Lecture.jsx';
|
import Lecture from './Lecture.jsx';
|
||||||
import Questions from './Questions.jsx';
|
import Questions from './Questions.jsx';
|
||||||
|
|
||||||
export default React.createClass({
|
export default contain(
|
||||||
|
{
|
||||||
|
actions: ['hikesActions']
|
||||||
|
},
|
||||||
|
React.createClass({
|
||||||
displayName: 'Hike',
|
displayName: 'Hike',
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
currentHike: PropTypes.object,
|
currentHike: PropTypes.object,
|
||||||
|
hikesActions: PropTypes.object,
|
||||||
|
params: PropTypes.object,
|
||||||
showQuestions: PropTypes.bool
|
showQuestions: PropTypes.bool
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentWillReceiveProps({ params: { dashedName }, showQuestions }) {
|
||||||
|
if (
|
||||||
|
showQuestions &&
|
||||||
|
this.props.params.dashedName !== dashedName
|
||||||
|
) {
|
||||||
|
this.props.hikesActions.toggleQuestions();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
renderBody(showQuestions) {
|
renderBody(showQuestions) {
|
||||||
if (showQuestions) {
|
if (showQuestions) {
|
||||||
return <Questions />;
|
return <Questions />;
|
||||||
@ -44,4 +60,5 @@ export default React.createClass({
|
|||||||
</Col>
|
</Col>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
);
|
||||||
|
@ -69,7 +69,7 @@ export default contain(
|
|||||||
<Row>
|
<Row>
|
||||||
<Vimeo
|
<Vimeo
|
||||||
onError={ this.handleError }
|
onError={ this.handleError }
|
||||||
onFinish= { this.handleFinish }
|
onFinish= { () => this.handleFinish(hikesActions) }
|
||||||
videoId={ id } />
|
videoId={ id } />
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
|
@ -88,7 +88,11 @@ export default Actions({
|
|||||||
toggleQuestions() {
|
toggleQuestions() {
|
||||||
return {
|
return {
|
||||||
transform(state) {
|
transform(state) {
|
||||||
const hikesApp = { ...state.hikesApp, showQuestions: true };
|
const hikesApp = {
|
||||||
|
...state.hikesApp,
|
||||||
|
showQuestions: !state.hikesApp.showQuestions,
|
||||||
|
currentQuestion: 1
|
||||||
|
};
|
||||||
return { ...state, hikesApp };
|
return { ...state, hikesApp };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user