File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ import { useEffect , useState } from 'react'
2+ import localforage from 'localforage'
13import './App.css'
24import Views from './views/Views'
35import { ContextWrapper } from './contexts/GlobalContext'
46import { YamlContextWrapper } from './contexts/YamlContext'
57
8+ const FILE_CACHE_KEYS = [
9+ 'files' ,
10+ 'fileList' ,
11+ 'imageFileList' ,
12+ 'labelFileList' ,
13+ 'currentImage' ,
14+ 'currentLabel' ,
15+ 'inputImage' ,
16+ 'inputLabel'
17+ ]
18+
619function App ( ) {
20+ const [ isCacheCleared , setIsCacheCleared ] = useState ( false )
21+
22+ useEffect ( ( ) => {
23+ const clearFileCache = async ( ) => {
24+ try {
25+ await Promise . all (
26+ FILE_CACHE_KEYS . map ( ( key ) => localforage . removeItem ( key ) )
27+ )
28+ } catch ( error ) {
29+ console . error ( 'Failed to clear file cache on startup:' , error )
30+ } finally {
31+ setIsCacheCleared ( true )
32+ }
33+ }
34+
35+ clearFileCache ( )
36+ } , [ ] )
37+
38+ if ( ! isCacheCleared ) {
39+ return null
40+ }
41+
742 return (
843 < ContextWrapper >
944 < YamlContextWrapper >
You can’t perform that action at this time.
0 commit comments