call getProcesses in componentDidMount

This commit is contained in:
Jonathan Rainville 2018-09-13 15:11:51 -04:00 committed by Pascal Precht
parent ae3185d96f
commit 86b2dcc2da
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 14 additions and 6 deletions

View File

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