Don't query completed steps if not logged in

This commit is contained in:
Itay Mizeretz 2018-02-22 16:18:14 +02:00
parent 28ef2d8708
commit 9e169980e3
1 changed files with 16 additions and 14 deletions

View File

@ -26,21 +26,23 @@ let guardicoreLogoImage = require('../images/guardicore-logo.png');
class AppComponent extends AuthComponent { class AppComponent extends AuthComponent {
updateStatus = () => { updateStatus = () => {
this.authFetch('/api') if (this.auth.loggedIn()){
.then(res => res.json()) this.authFetch('/api')
.then(res => { .then(res => res.json())
// This check is used to prevent unnecessary re-rendering .then(res => {
let isChanged = false; // This check is used to prevent unnecessary re-rendering
for (let step in this.state.completedSteps) { let isChanged = false;
if (this.state.completedSteps[step] !== res['completed_steps'][step]) { for (let step in this.state.completedSteps) {
isChanged = true; if (this.state.completedSteps[step] !== res['completed_steps'][step]) {
break; isChanged = true;
break;
}
} }
} if (isChanged) {
if (isChanged) { this.setState({completedSteps: res['completed_steps']});
this.setState({completedSteps: res['completed_steps']}); }
} });
}); }
}; };
renderRoute = (route_path, page_component, is_exact_path = false) => { renderRoute = (route_path, page_component, is_exact_path = false) => {