load tutorial only once
This commit is contained in:
parent
28720edeea
commit
2d29b8d7bd
@ -18,13 +18,14 @@ export const getTutorial = (id) => (dispatch, getState) => {
|
||||
type: GET_TUTORIAL,
|
||||
payload: tutorial
|
||||
});
|
||||
dispatch(returnSuccess(res.data.message, res.status));
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
dispatch({type: TUTORIAL_PROGRESS});
|
||||
if(err.response){
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'GET_TUTORIAL_FAIL'));
|
||||
}
|
||||
dispatch({type: TUTORIAL_PROGRESS});
|
||||
});
|
||||
};
|
||||
|
||||
@ -43,13 +44,14 @@ export const getTutorials = () => (dispatch, getState) => {
|
||||
payload: tutorials
|
||||
});
|
||||
dispatch({type: TUTORIAL_PROGRESS});
|
||||
dispatch(returnSuccess(res.data.message, res.status));
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
dispatch({type: TUTORIAL_PROGRESS});
|
||||
if(err.response){
|
||||
dispatch(returnErrors(err.response.data.message, err.response.status, 'GET_TUTORIALS_FAIL'));
|
||||
}
|
||||
dispatch({type: TUTORIAL_PROGRESS});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -22,17 +22,14 @@ class Tutorial extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
this.props.getTutorial(this.props.match.params.tutorialId);
|
||||
// this.props.tutorialId(Number(this.props.match.params.tutorialId));
|
||||
}
|
||||
|
||||
componentDidUpdate(props, state) {
|
||||
if (props.tutorial && props.tutorial.id && !props.isLoading && Number(props.tutorial.id) !== Number(this.props.match.params.tutorialId)) {
|
||||
if(this.props.tutorial && !this.props.isLoading && this.props.tutorial.id != this.props.match.params.tutorialId) {
|
||||
this.props.getTutorial(this.props.match.params.tutorialId);
|
||||
// this.props.tutorialId(Number(this.props.match.params.tutorialId));
|
||||
}
|
||||
if(this.props.message.id === 'GET_TUTORIAL_FAIL'){
|
||||
alert(this.props.message.msg);
|
||||
this.props.clearMessages();
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,11 +42,11 @@ class Tutorial extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
console.log(this.props.tutorial);
|
||||
return (
|
||||
<div>
|
||||
{this.props.isLoading ? null :
|
||||
!this.props.tutorial ? <NotFound button={{ title: 'Zurück zur Tutorials-Übersicht', link: '/tutorial' }} />
|
||||
!this.props.tutorial ?
|
||||
this.props.message.id === 'GET_TUTORIAL_FAIL' ? <NotFound button={{ title: 'Zurück zur Tutorials-Übersicht', link: '/tutorial' }} /> : null
|
||||
: (() => {
|
||||
var tutorial = this.props.tutorial;
|
||||
var steps = this.props.tutorial.steps;
|
||||
|
@ -58,7 +58,6 @@ class TutorialHome extends Component {
|
||||
componentDidUpdate(props, state) {
|
||||
if(this.props.message.id === 'GET_TUTORIALS_FAIL'){
|
||||
alert(this.props.message.msg);
|
||||
this.props.clearMessages();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
let tutorials = [
|
||||
require('./tutorial/ErsteSchritte.json'),
|
||||
require('./tutorial/Schleifen.json'),
|
||||
require('./tutorial/Wenn-DannBedingungen.json'),
|
||||
require('./tutorial/VerwendungVonVariablen.json'),
|
||||
require('./tutorial/SendenVonMesswertenUeberLoRa.json'),
|
||||
require('./tutorial/AnzeigeVonMesswertenAufDemDisplay.json'),
|
||||
require('./tutorial/MesswerteAnDieOpenSenseMapSenden.json')
|
||||
]
|
||||
|
||||
module.exports = tutorials;
|
||||
// let tutorials = [
|
||||
// require('./tutorial/ErsteSchritte.json'),
|
||||
// require('./tutorial/Schleifen.json'),
|
||||
// require('./tutorial/Wenn-DannBedingungen.json'),
|
||||
// require('./tutorial/VerwendungVonVariablen.json'),
|
||||
// require('./tutorial/SendenVonMesswertenUeberLoRa.json'),
|
||||
// require('./tutorial/AnzeigeVonMesswertenAufDemDisplay.json'),
|
||||
// require('./tutorial/MesswerteAnDieOpenSenseMapSenden.json')
|
||||
// ]
|
||||
//
|
||||
// module.exports = tutorials;
|
||||
|
Loading…
x
Reference in New Issue
Block a user