Skip to content

Commit af9022a

Browse files
RoderickXiiDanielGaran02Kelementz916anthonyHerrrobsinz
committed
repatch save function
Co-authored-by: Daniel Garan <[email protected]> Co-authored-by: Kevin Can <[email protected]> Co-authored-by: Anthony Herrera <[email protected]> Co-authored-by: Rob Sinzieri <[email protected]> Co-authored-by: Roderick de Leon <[email protected]>"
1 parent fe0fa0a commit af9022a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/components/Canvas.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ const colorModal = ref(false);
548548
const childrenSelected = ref<typeof VueMultiselect>([]);
549549
const boxes = ref<typeof VueDraggableResizable>(null);
550550
551-
//emitter
551+
//emitters
552552
defineEmits(["deactivated", "update:active", "activated"]);
553553
defineExpose({ boxes });
554554

src/components/nav-buttons/SaveProject.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<script setup lang="ts">
1919
/* IMPORTS */
2020
import { computed } from "vue";
21-
import { useStore } from "../../stores/main";
21+
import { useStore } from "../../stores/main.js";
2222
import localforage from "localforage";
2323
const Mousetrap = require("mousetrap");
2424
@@ -86,7 +86,6 @@ const parseAndDelete = (htmlList: any[]) => {
8686
const saveProjectJSON = () => showSaveJSONDialog();
8787
8888
const saveJSONLocation = (filePath: string) => {
89-
9089
let deleteKey = projects.value[activeTab.value].filename;
9190
localforage
9291
.removeItem(deleteKey)
@@ -97,17 +96,28 @@ const saveJSONLocation = (filePath: string) => {
9796
9897
let fileName: string | undefined = parseFileName(filePath);
9998
99+
100100
if (fileName) {
101101
addProject({
102102
filename: fileName,
103103
lastSavedLocation: filePath,
104104
});
105105
106-
let stateRef = JSON.parse(JSON.stringify(stateComputed.value));
106+
let cache: Array<any> | null = [];
107+
let stateRefString: string = JSON.stringify(stateComputed.value, (key: string, value: any) => {
108+
if (typeof value === 'object' && value !== null) {
109+
if (cache.includes(value)) return;
110+
cache.push(value);
111+
}
112+
return value;
113+
});
114+
let stateRef = JSON.parse(stateRefString);
115+
cache = null; // Enable garbage collection on cache
107116
108117
ipcRenderer
109118
.invoke('writeJSON', { filePath, data: JSON.stringify(stateRef) })
110119
.then(() => {
120+
111121
if (fileName) {
112122
localforage.setItem(fileName, stateRef);
113123
}
@@ -157,4 +167,4 @@ Mousetrap.bind(["command+s", "ctrl+s"], () => {
157167
margin-right: 2px;
158168
}
159169
</style>
160-
../../stores/main
170+

0 commit comments

Comments
 (0)