Skip to content

Commit 13ff28e

Browse files
committed
feat(store): save explorer state locally
1 parent 80a9250 commit 13ff28e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/store.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ export class ReplStore implements Store {
170170
if (!files[mainFile]) {
171171
mainFile = Object.keys(files)[0]
172172
}
173+
174+
const savedShowFileExplorer = localStorage.getItem('showFileExplorer')
175+
const showFileExplorer = savedShowFileExplorer !== null
176+
? savedShowFileExplorer === 'true'
177+
: true
178+
173179
this.state = reactive({
174180
mainFile,
175181
files,
@@ -180,7 +186,7 @@ export class ReplStore implements Store {
180186
typescriptVersion: 'latest',
181187
typescriptLocale: undefined,
182188
resetFlip: true,
183-
showFileExplorer: true,
189+
showFileExplorer,
184190
})
185191

186192
this.initImportMap()
@@ -196,6 +202,13 @@ export class ReplStore implements Store {
196202
)
197203
)
198204

205+
watch(
206+
() => this.state.showFileExplorer,
207+
(value) => {
208+
localStorage.setItem('showFileExplorer', String(value))
209+
}
210+
)
211+
199212
watch(
200213
() => [
201214
this.state.files[tsconfigFile]?.code,

0 commit comments

Comments
 (0)