Skip to content

Commit b69a7d7

Browse files
committed
fix initial typing errors in state
1 parent 6c30b11 commit b69a7d7

File tree

2 files changed

+60
-49
lines changed

2 files changed

+60
-49
lines changed

src/store/actions.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ import {
33
breadthFirstSearchParent,
44
} from "src/utils/search.util";
55

6-
import { State, Actions, Component, RouteComponentMap, HtmlElement } from "../../types";
6+
import {
7+
State,
8+
Actions,
9+
Component,
10+
RouteComponentMap,
11+
HtmlElement,
12+
} from "../../types";
713
import { Store } from "pinia";
814
import localforage from "localforage";
915
// *** GLOBAL *** //////////////////////////////////////////////
10-
16+
// @ts-ignore
1117
const actions: Store<"main", State, {}, Actions> = {
1218
emptyState() {
1319
this.$reset();
@@ -733,9 +739,10 @@ const actions: Store<"main", State, {}, Actions> = {
733739
},
734740

735741
addParent(payload) {
736-
const a = this.componentMap[payload.componentName].parent as { [key: string]: Component | RouteComponentMap }
737-
a[this.parentSelected] =
738-
this.componentMap[this.parentSelected];
742+
const a = this.componentMap[payload.componentName].parent as {
743+
[key: string]: Component | RouteComponentMap;
744+
};
745+
a[this.parentSelected] = this.componentMap[this.parentSelected];
739746
this.componentMap[this.parentSelected].children.push(payload.componentName);
740747
},
741748

@@ -1047,11 +1054,13 @@ const actions: Store<"main", State, {}, Actions> = {
10471054
this.componentMap[this.activeComponent].htmlList.forEach((el) => {
10481055
//adding class into it's child 1st layer
10491056
if (el.children.length !== 0) {
1050-
el.children.forEach((element: { id: string | number; class: string }) => {
1051-
if (payload.id === element.id) {
1052-
element.class = payload.class;
1057+
el.children.forEach(
1058+
(element: { id: string | number; class: string }) => {
1059+
if (payload.id === element.id) {
1060+
element.class = payload.class;
1061+
}
10531062
}
1054-
});
1063+
);
10551064
}
10561065
if (payload.id === el.id) {
10571066
el.class = payload.class;
@@ -1067,11 +1076,13 @@ const actions: Store<"main", State, {}, Actions> = {
10671076
if (active.htmlList)
10681077
this.componentMap[this.activeComponent].htmlList.forEach((el) => {
10691078
if (el.children.length !== 0) {
1070-
el.children.forEach((element: { id: string | number; binding: string | number }) => {
1071-
if (payload.id === element.id) {
1072-
element.binding = payload.binding;
1079+
el.children.forEach(
1080+
(element: { id: string | number; binding: string | number }) => {
1081+
if (payload.id === element.id) {
1082+
element.binding = payload.binding;
1083+
}
10731084
}
1074-
});
1085+
);
10751086
}
10761087
if (payload.id === el.id) {
10771088
el.binding = payload.binding;

src/store/state/index.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,96 @@
1-
import icons from './icons';
2-
import htmlElementMap from './htmlElementMap';
3-
import styleClassmap from './styleClassMap';
4-
import * as types from '../../../types';
1+
import icons from "./icons";
2+
import htmlElementMap from "./htmlElementMap";
3+
import styleClassmap from "./styleClassMap";
4+
import * as types from "../../../types";
55

6-
const cloneDeep = require('lodash.clonedeep');
6+
const cloneDeep = require("lodash.clonedeep");
77

8-
const newState :types.State = {
9-
clicked:false,
8+
const newState: types.State = {
9+
clicked: false,
1010
icons,
1111
htmlElementMap,
1212
componentMap: {
1313
App: {
14-
componentName: 'App',
15-
children: ['HomeView'],
16-
htmlList: []
14+
componentName: "App",
15+
children: ["HomeView"],
16+
htmlList: [],
1717
},
1818
HomeView: {
19-
componentName: 'HomeView',
19+
componentName: "HomeView",
2020
children: [],
2121
htmlList: [],
22-
}
22+
},
2323
},
2424
routes: {
25-
HomeView: []
25+
HomeView: [],
2626
},
2727
userActions: [],
2828
userProps: [],
2929
userState: [],
3030
imagePath: {
31-
HomeView: ''
31+
HomeView: "",
3232
},
33-
componentNameInputValue: '',
34-
projects: [{ filename: 'Untitled-1', lastSavedLocation: '' }],
33+
componentNameInputValue: "",
34+
projects: [{ filename: "Untitled-1", lastSavedLocation: "" }],
3535

36-
activeRoute: 'HomeView',
36+
activeRoute: "HomeView",
3737
// need to change to activeComponentName
38-
activeComponent: '',
38+
activeComponent: "",
3939
activeComponentObj: null,
40-
activeHTML: '',
40+
activeHTML: "",
4141
activeLayer: {
42-
id: '',
43-
lineage: []
42+
id: "",
43+
lineage: [],
4444
},
4545

4646
selectedProps: [],
4747
selectedState: [],
4848
selectedActions: [],
4949
selectedElementList: [],
50-
selectedIdDrag: '',
51-
selectedIdDrop: '',
50+
selectedIdDrag: "",
51+
selectedIdDrop: "",
5252
projectNumber: 2,
5353
activeTab: 0,
54-
componentChildrenMultiselectValue: [],
54+
// componentChildrenMultiselectValue: [],
5555
modalOpen: false,
5656
attributeModalOpen: false,
5757
noteModalOpen: false,
5858
//test
5959
noteAttributeOpen: false,
6060
colorModalOpen: false,
61-
parentSelected: false,
61+
parentSelected: "",
6262
// for storing copied component
6363
copiedComponent: {},
6464
copyNumber: 0,
6565
pastedComponent: {},
66-
exportAsTypescript: 'off',
67-
exportOauth: 'off',
68-
exportOauthGithub: 'off',
66+
exportAsTypescript: "off",
67+
exportOauth: "off",
68+
exportOauthGithub: "off",
6969
showTutorial: true,
7070
tutorialFirstOpen: true,
7171
pasteTimer: 0,
7272
gridLayout: [15, 15], // [Width Ratio, Height Ratio] this will be used to have containerH / gridLayout[0] and have fr
7373
containerH: 720, // in px
7474
containerW: 1280, // in px
75-
importLibraries:[],
76-
displaylibComponent:false,
77-
importTest:'off'
75+
importLibraries: [],
76+
displaylibComponent: false,
77+
importTest: "off",
7878
//push libraries string to the array
7979
};
8080

8181
// closured method to ensure we only ever write the default state ONCE
82-
const writeTheDefault = ():any => {
83-
let initial:object = {};
84-
let needsToRun:boolean = true;
85-
function onced(payload:any) {
82+
const writeTheDefault = (): any => {
83+
let initial: object = {};
84+
let needsToRun: boolean = true;
85+
function onced(payload: any) {
8686
if (needsToRun) {
8787
initial = cloneDeep(payload);
8888
needsToRun = false;
8989
}
9090
return initial;
9191
}
9292
return onced;
93-
}
93+
};
9494

9595
const defaultState = writeTheDefault();
9696

0 commit comments

Comments
 (0)