Skip to content

Commit 7bf881d

Browse files
authored
Merge pull request #4 from oslabs-beta/typescript
Typescript
2 parents c216faf + 6ad9277 commit 7bf881d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3475
-2392
lines changed

package-lock.json

Lines changed: 119 additions & 165 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@quasar/cli": "^1.3.2",
2929
"@quasar/extras": "^1.12.5",
3030
"@ssthouse/vue3-tree-chart": "^0.2.3",
31+
"@types/node": "^18.8.0",
3132
"@typescript-eslint/eslint-plugin": "^5.36.2",
3233
"@typescript-eslint/parser": "^5.36.2",
3334
"bootstrap": "^5.2.0",
@@ -55,6 +56,7 @@
5556
"vue": "^3.2.31",
5657
"vue-accessible-color-picker": "^4.0.3",
5758
"vue-draggable-resizable": "^2.3.0",
59+
"vue-loader": "^17.0.0",
5860
"vue-multiselect": "^3.0.0-alpha.2",
5961
"vue-prism-editor": "^2.0.0-alpha.2",
6062
"vue-router": "4.0.13",
@@ -67,6 +69,7 @@
6769
},
6870
"devDependencies": {
6971
"@babel/eslint-parser": "^7.17.0",
72+
"@pinia/testing": "^0.0.14",
7073
"@quasar/app": "^3.3.3",
7174
"@quasar/quasar-app-extension-testing-unit-jest": "^3.0.0-alpha.7",
7275
"@vue/devtools": "^6.0.12",

src/App.vue

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
/>
1010
</template>
1111

12-
<script>
13-
export default {
14-
name: "App",
15-
};
16-
</script>
17-
1812
<script setup>
1913
// import { defineComponent } from "vue";
2014
// import ElementPlus from 'element-plus'; // importing element plus component library
@@ -41,19 +35,19 @@ const isTimetraveling = ref(false);
4135
4236
const store = useStore();
4337
44-
const subscribeAction = store.$subscribe((action, state) => {
45-
if (typeof action.payload === "object") {
46-
action.payload = cloneDeep(action.payload);
38+
store.$onAction((action) => {
39+
if (typeof action.args[0] === "object") {
40+
action.args = cloneDeep(action.args[0]);
4741
}
4842
doneAction.value.push(action);
4943
if (!isTimetraveling.value) {
5044
if (undoneAction.value[undoneAction.value.length - 1]) {
5145
if (
52-
action.type ===
53-
undoneAction.value[undoneAction.value.length - 1].type &&
46+
action.name ===
47+
undoneAction.value[undoneAction.value.length - 1].name &&
5448
deepEqual(
55-
action.payload,
56-
undoneAction.value[undoneAction.value.length - 1].payload
49+
action.args,
50+
undoneAction.value[undoneAction.value.length - 1].args[0]
5751
)
5852
) {
5953
undoneAction.value.pop();
@@ -98,10 +92,10 @@ const undo = () => {
9892
if this happens we keep popping the doneAction.value queue and building up the redo queue. */
9993
if (undone !== undefined) {
10094
undoneAction.value.push(undone);
101-
if (ignoredActions.has(undone.type)) {
95+
if (ignoredActions.has(undone.name)) {
10296
while (
10397
doneAction.value[doneAction.value.length - 1] &&
104-
ignoredActions.has(doneAction.value[doneAction.value.length - 1].type)
98+
ignoredActions.has(doneAction.value[doneAction.value.length - 1].name)
10599
) {
106100
undoneAction.value.push(doneAction.value.pop());
107101
}
@@ -117,9 +111,8 @@ const undo = () => {
117111
store.emptyState();
118112
119113
doneAction.value.forEach((action) => {
120-
const actionType = action.type;
121-
store.action.type(cloneDeep(action.payload));
122-
doneAction.pop();
114+
store[action.name](cloneDeep(action.args[0]));
115+
doneAction.value.pop();
123116
});
124117
isTimetraveling.value = false;
125118
};
@@ -130,11 +123,11 @@ const redo = () => {
130123
// we have to set timeTraveling to true to preserve the undoneAction array while we make changes
131124
isTimetraveling.value = true;
132125
if (action) {
133-
const actionType = action.type;
134-
store[actionType](cloneDeep(action.payload));
126+
const actionName = action.name;
127+
store[actionName](cloneDeep(action.args[0]));
135128
}
136129
isTimetraveling.value = false;
137-
if (action && ignoredActions.has(action.type)) {
130+
if (action && ignoredActions.has(action.name)) {
138131
redo();
139132
}
140133
};

0 commit comments

Comments
 (0)