fix bugs with saving/fetching projects

This commit is contained in:
catarak 2016-06-29 12:52:16 -04:00
parent 21a2b25add
commit aa0637c256
6 changed files with 19 additions and 9 deletions

View file

@ -48,6 +48,7 @@ I'm new to using ESLint, but I decided on a configuration based on some popular
##Dump of links I'm saving for reference ##Dump of links I'm saving for reference
* https://github.com/brigade/scss-lint
* https://github.com/petehunt/react-howto * https://github.com/petehunt/react-howto
* https://github.com/jsbin/jsbin (especially look at the console) * https://github.com/jsbin/jsbin (especially look at the console)
* Need to figure out how to solve the XSS issue, https://github.com/jsbin/jsbin/wiki/Best-practices-for-building-your-own-live-paste-bin * Need to figure out how to solve the XSS issue, https://github.com/jsbin/jsbin/wiki/Best-practices-for-building-your-own-live-paste-bin

View file

@ -11,7 +11,8 @@ export function getProject(id) {
browserHistory.push(`/projects/${id}`); browserHistory.push(`/projects/${id}`);
dispatch({ dispatch({
type: ActionTypes.SET_PROJECT, type: ActionTypes.SET_PROJECT,
project: response.data project: response.data,
file: response.data.file
}); });
}) })
.catch(response => dispatch({ .catch(response => dispatch({

View file

@ -21,7 +21,12 @@ const file = (state = initialState, action) => {
case ActionTypes.NEW_PROJECT: case ActionTypes.NEW_PROJECT:
return { return {
name: action.file.name, name: action.file.name,
content: action.file.conent content: action.file.content
};
case ActionTypes.SET_PROJECT:
return {
name: action.file.name,
content: action.file.content
}; };
default: default:
return state; return state;

View file

@ -18,11 +18,7 @@ const project = (state = initialState, action) => {
case ActionTypes.SET_PROJECT: case ActionTypes.SET_PROJECT:
return { return {
id: action.project.id, id: action.project.id,
name: action.project.name, name: action.project.name
file: {
name: action.project.file.name,
content: action.project.file.content
}
}; };
default: default:
return state; return state;

View file

@ -49,7 +49,7 @@ export function getProject(req, res) {
name: project.name, name: project.name,
file: { file: {
name: project.file.name, name: project.file.name,
content: project.file.conent content: project.file.content
} }
}); });
}); });

View file

@ -2,9 +2,16 @@ import mongoose from 'mongoose';
const Schema = mongoose.Schema; const Schema = mongoose.Schema;
import shortid from 'shortid'; import shortid from 'shortid';
const defaultSketch = `setup() {
createCanvas(400, 400);
}
draw() {
background(220);
}`
const fileSchema = new Schema({ const fileSchema = new Schema({
name: { type: String, default: 'sketch.js' }, name: { type: String, default: 'sketch.js' },
content: { type: String } content: { type: String, default: defaultSketch }
}, { timestamps: true }); }, { timestamps: true });
const projectSchema = new Schema({ const projectSchema = new Schema({