Fixes #1052, in which a user can't save a sketch after uploading a file
This commit is contained in:
parent
c3de0512cc
commit
8b296a51aa
3 changed files with 19 additions and 4 deletions
|
@ -4,6 +4,7 @@ import blobUtil from 'blob-util';
|
|||
import { reset } from 'redux-form';
|
||||
import * as ActionTypes from '../../../constants';
|
||||
import { setUnsavedChanges } from './ide';
|
||||
import { setProjectSavedTime } from './project';
|
||||
|
||||
const __process = (typeof global !== 'undefined' ? global : window).process;
|
||||
const ROOT_URL = __process.env.API_URL;
|
||||
|
@ -60,9 +61,10 @@ export function createFile(formProps) {
|
|||
.then((response) => {
|
||||
dispatch({
|
||||
type: ActionTypes.CREATE_FILE,
|
||||
...response.data,
|
||||
...response.data.updatedFile,
|
||||
parentId
|
||||
});
|
||||
dispatch(setProjectSavedTime(response.data.project.updatedAt));
|
||||
dispatch(reset('new-file'));
|
||||
// dispatch({
|
||||
// type: ActionTypes.HIDE_MODAL
|
||||
|
@ -117,9 +119,10 @@ export function createFolder(formProps) {
|
|||
.then((response) => {
|
||||
dispatch({
|
||||
type: ActionTypes.CREATE_FILE,
|
||||
...response.data,
|
||||
...response.data.updatedFile,
|
||||
parentId
|
||||
});
|
||||
dispatch(setProjectSavedTime(response.data.project.updatedAt));
|
||||
dispatch({
|
||||
type: ActionTypes.CLOSE_NEW_FOLDER_MODAL
|
||||
});
|
||||
|
|
|
@ -328,3 +328,10 @@ export function hideEditProjectName() {
|
|||
type: ActionTypes.HIDE_EDIT_PROJECT_NAME
|
||||
};
|
||||
}
|
||||
|
||||
export function setProjectSavedTime(updatedAt) {
|
||||
return {
|
||||
type: ActionTypes.SET_PROJECT_SAVED_TIME,
|
||||
value: updatedAt
|
||||
};
|
||||
}
|
||||
|
|
|
@ -28,13 +28,18 @@ export function createFile(req, res) {
|
|||
}
|
||||
const newFile = updatedProject.files[updatedProject.files.length - 1];
|
||||
updatedProject.files.id(req.body.parentId).children.push(newFile.id);
|
||||
updatedProject.save((innerErr) => {
|
||||
updatedProject.save((innerErr, savedProject) => {
|
||||
if (innerErr) {
|
||||
console.log(innerErr);
|
||||
res.json({ success: false });
|
||||
return;
|
||||
}
|
||||
res.json(updatedProject.files[updatedProject.files.length - 1]);
|
||||
savedProject.populate({ path: 'user', select: 'username' }, (_, populatedProject) => {
|
||||
res.json({
|
||||
updatedFile: updatedProject.files[updatedProject.files.length - 1],
|
||||
project: populatedProject
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue