Merge pull request #266 from guardicore/hotfix/remove-unecessary-set-state

Some unecessary set states removed to prevent refreshing of config page
This commit is contained in:
itaymmguardicore 2019-02-17 14:08:54 +02:00 committed by GitHub
commit ee7c9d9ea8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -29,9 +29,11 @@ class AppComponent extends AuthComponent {
updateStatus = () => {
this.auth.loggedIn()
.then(res => {
if (this.state.isLoggedIn !== res) {
this.setState({
isLoggedIn: res
});
}
if (res) {
this.authFetch('/api')

View File

@ -141,9 +141,12 @@ class ConfigurePageComponent extends AuthComponent {
.then(res => res.json())
.then(res => {
// This check is used to prevent unnecessary re-rendering
let allMonkeysAreDead = (!res['completed_steps']['run_monkey']) || (res['completed_steps']['infection_done']);
if (allMonkeysAreDead !== this.state.allMonkeysAreDead) {
this.setState({
allMonkeysAreDead: (!res['completed_steps']['run_monkey']) || (res['completed_steps']['infection_done'])
allMonkeysAreDead: allMonkeysAreDead
});
}
});
};