call getProcesses in componentDidMount

This commit is contained in:
Jonathan Rainville 2018-09-13 15:11:51 -04:00 committed by Iuri Matias
parent 0e44722eb6
commit 609ba0f1a1
1 changed files with 14 additions and 6 deletions

View File

@ -12,17 +12,25 @@ import {getProcesses, getCommands, getVersions, getProcessLogs} from "../reducer
import deepEqual from 'deep-equal';
class HomeContainer extends Component {
componentDidMount() {
this.getProcesses();
}
componentDidUpdate(prevProps) {
if (!deepEqual(this.props.processes, prevProps.processes)) {
this.props.processes.forEach(process => {
this.props.fetchProcessLogs(process.name);
if (!prevProps.processes.length) {
this.props.listenToProcessLogs(process.name);
}
});
this.getProcesses(prevProps);
}
}
getProcesses(prevProps) {
this.props.processes.forEach(process => {
this.props.fetchProcessLogs(process.name);
if (!prevProps || !prevProps.processes.length) {
this.props.listenToProcessLogs(process.name);
}
});
}
render() {
return (
<React.Fragment>