add open sketch func

This commit is contained in:
casperlamboo 2017-11-14 19:02:29 +01:00
parent e6cda7fbdb
commit 62847f4064
2 changed files with 27 additions and 2 deletions

View File

@ -85,6 +85,7 @@ export const FLOOD_FILL = 'FLOOD_FILL';
export const TRACE_FLOOD_FILL = 'TRACE_FLOOD_FILL';
export const MENU_OPEN = 'MENU_OPEN';
export const MENU_CLOSE = 'MENU_CLOSE';
export const OPEN_SKETCH = 'OPEN_SKETCH';
// CATEGORIES
// actions that influence selected objects
@ -494,3 +495,7 @@ export function menuOpen(menuValue) {
export function menuClose(menuValue) {
return { type: MENU_CLOSE, menuValue };
}
export function openSketch(data) {
return { type: OPEN_SKETCH };
}

View File

@ -207,11 +207,31 @@ function sketcherReducer(state = initialState, action) {
state = updateMenus(state, action);
return state;
// actions.user.USER_LOGOUT_FULFILLED
// actions.files.FILES_LOAD_FULFILLED:
case actions.CLEAR:
return initialState;
case actions.OPEN_SKETCH:
let first = true;
for (const space of action.data.data.spaces) {
if (first) {
state = addSpaceActive(state, space.matrix, 'world');
} else {
state = addSpaceActive(state, space.matrix);
}
for (const object of space.objects) {
if (first) {
state = addObject(state, { ...object, space: 'world' });
} else {
state = addObject(state, object);
}
}
first = false;
}
return setActiveSpace(state, 'world');
case actions.DUPLICATE_SELECTION:
case actions.DELETE_SELECTION:
case actions.UNION: