From 3a0139340c190f1392cc46972500c9a59b66411c Mon Sep 17 00:00:00 2001 From: "Mr.tang" <1074461480@qq.com> Date: Tue, 20 Feb 2018 13:44:07 -0600 Subject: [PATCH] Fixes #470 #419 #437 (#546) * add status check * rename variables and remove unnecessary dependencies * set unsavedchange when error happens * set unsavedchange when error happens --- client/modules/IDE/actions/project.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/client/modules/IDE/actions/project.js b/client/modules/IDE/actions/project.js index 4a9ac140..4b299137 100644 --- a/client/modules/IDE/actions/project.js +++ b/client/modules/IDE/actions/project.js @@ -2,6 +2,7 @@ import { browserHistory } from 'react-router'; import axios from 'axios'; import objectID from 'bson-objectid'; import each from 'async/each'; +import { isEqual } from 'lodash'; import * as ActionTypes from '../../../constants'; import { showToast, setToastText } from './toast'; import { setUnsavedChanges, @@ -81,9 +82,15 @@ export function saveProject(autosave = false) { if (state.project.id) { return axios.put(`${ROOT_URL}/projects/${state.project.id}`, formParams, { withCredentials: true }) .then((response) => { - dispatch(setUnsavedChanges(false)); - console.log(response.data); - dispatch(setProject(response.data)); + const currentState = getState(); + const savedProject = Object.assign({}, response.data); + if (!isEqual(currentState.files, response.data.files)) { + savedProject.files = currentState.files; + dispatch(setUnsavedChanges(true)); + } else { + dispatch(setUnsavedChanges(false)); + } + dispatch(setProject(savedProject)); dispatch({ type: ActionTypes.PROJECT_SAVE_SUCCESS });