remove toasts for autosave

This commit is contained in:
catarak 2016-09-07 22:20:42 -04:00
parent 380b960328
commit 861a8f8759
2 changed files with 17 additions and 9 deletions

View file

@ -47,7 +47,7 @@ export function setProjectName(name) {
};
}
export function saveProject() {
export function saveProject(autosave) {
return (dispatch, getState) => {
const state = getState();
if (state.user.id && state.project.owner && state.project.owner.id !== state.user.id) {
@ -61,8 +61,10 @@ export function saveProject() {
dispatch({
type: ActionTypes.PROJECT_SAVE_SUCCESS
});
if (!autosave) {
dispatch(showToast());
dispatch(setToastText('Project saved.'));
}
})
.catch((response) => dispatch({
type: ActionTypes.PROJECT_SAVE_FAIL,
@ -79,10 +81,8 @@ export function saveProject() {
owner: response.data.user,
files: response.data.files
});
if (!autosave) {
dispatch(showToast());
if (state.preferences.autosave) {
dispatch(setToastText('Autosave enabled.'));
} else {
dispatch(setToastText('Project saved.'));
}
})
@ -94,6 +94,11 @@ export function saveProject() {
};
}
export function autosaveProject() {
return (dispatch, getState) => {
saveProject(true)(dispatch, getState);
};
}
export function createProject() {
return (dispatch) => {

View file

@ -45,7 +45,7 @@ class IDEView extends React.Component {
if (this.props.preferences.autosave
&& this.props.project.owner
&& this.props.project.owner.id === this.props.user.id) {
this.autosaveInterval = setInterval(this.props.saveProject, 30000);
this.autosaveInterval = setInterval(this.props.autosaveProject, 30000);
}
}
@ -79,7 +79,7 @@ class IDEView extends React.Component {
if (!this.autosaveInterval &&
((this.props.preferences.autosave && !prevProps.preferences.autosave) ||
(this.props.project.id && !prevProps.project.id))) {
this.autosaveInterval = setInterval(this.props.saveProject, 30000);
this.autosaveInterval = setInterval(this.props.autosaveProject, 30000);
// if user turns off autosave preference
} else if (this.autosaveInterval && !this.props.preferences.autosave && prevProps.preferences.autosave) {
clearInterval(this.autosaveInterval);
@ -454,6 +454,9 @@ IDEView.propTypes = {
toast: PropTypes.shape({
isVisible: PropTypes.bool.isRequired
}).isRequired,
showToast: PropTypes.func.isRequired,
setToastText: PropTypes.func.isRequired,
autosaveProject: PropTypes.func.isRequired
};
function mapStateToProps(state) {