fix default file on server, change file to files in lots of places

This commit is contained in:
catarak 2016-07-06 17:29:07 -04:00
parent e6d94a0db8
commit 6e12ed6524
4 changed files with 10 additions and 25 deletions

View file

@ -12,7 +12,7 @@ export function getProject(id) {
dispatch({
type: ActionTypes.SET_PROJECT,
project: response.data,
file: response.data.file
files: response.data.files
});
})
.catch(response => dispatch({
@ -54,10 +54,7 @@ export function saveProject() {
type: ActionTypes.NEW_PROJECT,
name: response.data.name,
id: response.data.id,
file: {
name: response.data.file.name,
content: response.data.file.content
}
files: response.data.files
});
})
.catch(response => dispatch({
@ -78,10 +75,7 @@ export function createProject() {
type: ActionTypes.NEW_PROJECT,
name: response.data.name,
id: response.data.id,
file: {
name: response.data.file.name,
content: response.data.file.content
}
files: response.data.files
});
})
.catch(response => dispatch({

View file

@ -45,9 +45,9 @@ const files = (state = initialState, action) => {
};
});
case ActionTypes.NEW_PROJECT:
return { ...action.files };
return [...action.files];
case ActionTypes.SET_PROJECT:
return { ...action.files };
return [...action.files];
default:
return state;
}

View file

@ -13,10 +13,7 @@ export function createProject(req, res) {
return res.json({
id: newProject._id, // eslint-disable-line no-underscore-dangle
name: newProject.name,
file: {
name: newProject.file.name,
content: newProject.file.content
}
files: newProject.files
});
});
}
@ -30,10 +27,7 @@ export function updateProject(req, res) {
return res.json({
id: updatedProject._id, // eslint-disable-line no-underscore-dangle
name: updatedProject.name,
file: {
name: updatedProject.file.name,
content: updatedProject.file.content
}
file: updatedProject.files
});
});
}
@ -47,10 +41,7 @@ export function getProject(req, res) {
return res.json({
id: project._id, // eslint-disable-line no-underscore-dangle
name: project.name,
file: {
name: project.file.name,
content: project.file.content
}
files: project.files
});
});
}

View file

@ -2,10 +2,10 @@ import mongoose from 'mongoose';
const Schema = mongoose.Schema;
import shortid from 'shortid';
const defaultSketch = `setup() {
const defaultSketch = `function setup() {
createCanvas(400, 400);
}
draw() {
function draw() {
background(220);
}`