2016-06-22 21:58:23 +02:00
|
|
|
import * as ActionTypes from '../../../constants';
|
2016-05-05 23:48:26 +02:00
|
|
|
|
|
|
|
const initialState = {
|
|
|
|
name: "sketch.js",
|
2016-05-10 00:28:38 +02:00
|
|
|
content: `function setup() {
|
|
|
|
createCanvas(400, 400);
|
|
|
|
}
|
|
|
|
|
|
|
|
function draw() {
|
|
|
|
background(220);
|
|
|
|
}`
|
2016-05-05 23:48:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const file = (state = initialState, action) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.CHANGE_SELECTED_FILE:
|
|
|
|
return {
|
|
|
|
name: action.name,
|
|
|
|
content: action.content
|
|
|
|
}
|
2016-06-17 22:40:13 +02:00
|
|
|
case ActionTypes.NEW_PROJECT:
|
|
|
|
return {
|
|
|
|
name: action.file.name,
|
|
|
|
content: action.file.conent
|
|
|
|
}
|
2016-05-05 23:48:26 +02:00
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default file;
|
|
|
|
|
|
|
|
//i'll add this in when there are multiple files
|
|
|
|
// const files = (state = [], action) => {
|
|
|
|
// switch (action.type) {
|
|
|
|
// case ActionTypes.CHANGE_SELECTED_FILE:
|
|
|
|
// //find the file with the name
|
|
|
|
// //update it
|
|
|
|
// //put in into the new array of files
|
|
|
|
// default:
|
|
|
|
// return state
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// export default files
|