fix bugs with saving/fetching projects
This commit is contained in:
parent
21a2b25add
commit
aa0637c256
6 changed files with 19 additions and 9 deletions
|
@ -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
|
||||||
|
|
|
@ -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({
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -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({
|
||||||
|
|
Loading…
Reference in a new issue