add autosave after new project is saved for the first time

This commit is contained in:
catarak 2016-08-03 21:47:24 -04:00
parent d7a6773995
commit 3d18960575
1 changed files with 7 additions and 0 deletions

View File

@ -25,6 +25,12 @@ class IDEView extends React.Component {
}
}
componentDidUpdate(prevProps) {
if (!this.autosaveInterval && this.props.project.id && !prevProps.project.id) {
this.autosaveInterval = setInterval(this.props.saveProject, 30000);
}
}
componentWillUnmount() {
clearInterval(this.autosaveInterval);
this.autosaveInterval = null;
@ -138,6 +144,7 @@ IDEView.propTypes = {
startSketch: PropTypes.func.isRequired,
stopSketch: PropTypes.func.isRequired,
project: PropTypes.shape({
id: PropTypes.string,
name: PropTypes.string.isRequired,
owner: PropTypes.shape({
username: PropTypes.string