Skip to content

Commit 6559298

Browse files
authored
Merge pull request #33 from keliphan/master
comment fixes
2 parents 82b0365 + 5c51404 commit 6559298

File tree

2 files changed

+14
-134
lines changed

2 files changed

+14
-134
lines changed

src/store/mutations.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,9 @@
11
import * as types from './types'
2-
// import icons from './state/icons.js'
3-
// import htmlElementMap from './state/htmlElementMap.js'
42
const cloneDeep = require('lodash.clonedeep')
5-
// import VuexStore from './index'
6-
// import { getDefault, defaultState } from './state/index.js'
73
import { breadthFirstSearch, breadthFirstSearchParent } from '../utils/search.util'
84

95
import localforage from 'localforage'
106

11-
// we have to do a search because undo/redo saves payloads as deep clones so passing a memory ref would be detrimental
12-
// This will find you the actual object by ID
13-
// const breadthFirstSearch = (array, id) => {
14-
// let queue = [...array.filter(el => typeof el === 'object')]
15-
// while (queue.length) {
16-
// let evaluated = queue.shift()
17-
// if (evaluated.id === id) {
18-
// return evaluated
19-
// } else {
20-
// if (evaluated.children.length) {
21-
// queue.push(...evaluated.children)
22-
// }
23-
// }
24-
// }
25-
// // console.log("We shouldn't be ever getting here, how did you even search an id that didn't exist?")
26-
// }
27-
28-
// // this would find you the parent of a given id
29-
// const breadthFirstSearchParent = (array, id) => {
30-
// let queue = [...array.filter(el => typeof el === 'object')]
31-
// while (queue.length) {
32-
// let evaluated = queue.shift()
33-
// for (let i = 0; i < evaluated.children.length; i++) {
34-
// if (evaluated.children[i].id === id) {
35-
// return {
36-
// evaluated: evaluated,
37-
// index: i
38-
// }
39-
// }
40-
// if (evaluated.children.length) {
41-
// queue.push(...evaluated.children)
42-
// }
43-
// }
44-
// // console.log("We shouldn't be ever getting here, how did you even search an id that didn't exist?")
45-
// }
46-
// }
477
const mutations = {
488
// invoked on undo, resetsstate to a cdeep clone of the initial state
499
[types.EMPTY_STATE]: (state, payload) => {

src/store/state/index.js

Lines changed: 14 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,10 @@ import icons from './icons'
22
import htmlElementMap from './htmlElementMap'
33
const cloneDeep = require('lodash.clonedeep')
44

5-
// let hardA = {
6-
// componentName: "a",
7-
// x: 0,
8-
// y: 20,
9-
// z: 0,
10-
// w: 200,
11-
// h: 200,
12-
// htmlList: [{
13-
// children:[{
14-
// children:[{
15-
// text: 'button',
16-
// children:[],
17-
// id:0
18-
// }],
19-
// text:'form',
20-
// id:2
21-
// }],
22-
// text: "div",
23-
// id:1
24-
// }],
25-
// children: [],
26-
// parent: {},
27-
// isActive: false
28-
// }
29-
305
const newState = {
316
icons,
327
htmlElementMap,
33-
// every single time we create a component
34-
// sent to export project component
8+
// state below is what is used when exporting a project
359
componentMap: {
3610
App: {
3711
componentName: 'App',
@@ -40,53 +14,46 @@ const newState = {
4014
},
4115
HomeView: {
4216
componentName: 'HomeView',
43-
// children: ['a'],
4417
children: [],
4518
htmlList: []
4619
}
47-
// NewView: {}
48-
// a: hardA
4920
},
5021
routes: {
51-
// HomeView: [hardA]
5222
HomeView: []
53-
// NewView: []
5423
},
5524
userActions: [],
5625
userState: {},
57-
/**
58-
*
59-
*/
26+
imagePath: {
27+
HomeView: ''
28+
},
29+
// state below is not used when exporting a project
6030
componentNameInputValue: '',
6131
projects: [{ filename: 'Untitled-1', lastSavedLocation: '' }],
6232

6333
activeRoute: 'HomeView',
6434
activeComponent: '',
6535
activeHTML: '',
6636
activeLayer: {
67-
id:'',
68-
lineage:[]
37+
id: '',
38+
lineage: []
6939
},
7040

7141
selectedElementList: [],
7242
projectNumber: 2,
7343
activeTab: 0,
7444
componentChildrenMultiselectValue: [],
7545
modalOpen: false,
76-
parentSelected: false,
77-
imagePath: {
78-
HomeView: ''
79-
}
46+
parentSelected: false
8047
}
8148

82-
//closured method to ensure we only ever write the default state ONCE
49+
// closured method to ensure we only ever write the default state ONCE
8350
const writeTheDefault = () => {
8451
let initial = {}
85-
let needsToRun = true;
86-
function onced(payload){
87-
if(needsToRun){
52+
let needsToRun = true
53+
function onced (payload) {
54+
if (needsToRun) {
8855
initial = cloneDeep(payload)
89-
needsToRun = false;
56+
needsToRun = false
9057
}
9158
return initial
9259
}
@@ -95,52 +62,5 @@ const writeTheDefault = () => {
9562

9663
const defaultState = writeTheDefault()
9764

98-
// const defaultState =
99-
// {
100-
// icons,
101-
// htmlElementMap,
102-
// // every single time we create a component
103-
// // sent to export project component
104-
// componentMap: {
105-
// App: {
106-
// componentName: 'App',
107-
// children: ['HomeView'],
108-
// htmlList: []
109-
// },
110-
// HomeView: {
111-
// componentName: 'HomeView',
112-
// children: [],
113-
// htmlList: []
114-
// }
115-
// // NewView: {}
116-
// },
117-
// routes: {
118-
// HomeView: []
119-
// // NewView: []
120-
// },
121-
// userActions: [],
122-
// userState: {},
123-
// /**
124-
// *
125-
// */
126-
// componentNameInputValue: '',
127-
// projects: [{ filename: 'Untitled-1', lastSavedLocation: '' }],
128-
// activeRoute: 'HomeView',
129-
// activeComponent: '',
130-
// selectedElementList: [],
131-
// projectNumber: 2,
132-
// activeTab: 0,
133-
// componentChildrenMultiselectValue: [],
134-
// modalOpen: false,
135-
// parentSelected: false,
136-
// imagePath: ''
137-
// }
138-
139-
// const getDefault = ()=>{
140-
// return {...defaultState}
141-
// }
142-
143-
144-
14565
export default newState
146-
export {defaultState}
66+
export { defaultState }

0 commit comments

Comments
 (0)