18
18
<script setup lang="ts">
19
19
/* IMPORTS */
20
20
import { computed } from " vue" ;
21
- import { useStore } from " ../../stores/main" ;
21
+ import { useStore } from " ../../stores/main.js " ;
22
22
import localforage from " localforage" ;
23
23
const Mousetrap = require (" mousetrap" );
24
24
@@ -86,7 +86,6 @@ const parseAndDelete = (htmlList: any[]) => {
86
86
const saveProjectJSON = () => showSaveJSONDialog ();
87
87
88
88
const saveJSONLocation = (filePath : string ) => {
89
-
90
89
let deleteKey = projects .value [activeTab .value ].filename ;
91
90
localforage
92
91
.removeItem (deleteKey )
@@ -97,17 +96,28 @@ const saveJSONLocation = (filePath: string) => {
97
96
98
97
let fileName: string | undefined = parseFileName (filePath );
99
98
99
+
100
100
if (fileName ) {
101
101
addProject ({
102
102
filename: fileName ,
103
103
lastSavedLocation: filePath ,
104
104
});
105
105
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
107
116
108
117
ipcRenderer
109
118
.invoke (' writeJSON' , { filePath , data: JSON .stringify (stateRef ) })
110
119
.then (() => {
120
+
111
121
if (fileName ) {
112
122
localforage .setItem (fileName , stateRef );
113
123
}
@@ -157,4 +167,4 @@ Mousetrap.bind(["command+s", "ctrl+s"], () => {
157
167
margin-right : 2px ;
158
168
}
159
169
</style >
160
- ../../stores/main
170
+
0 commit comments