| | |
| | | // Get folder state from local storage |
| | | const storageTree = localStorage.getItem("fileTree") |
| | | const serializedExplorerState = storageTree && opts.useSavedState ? JSON.parse(storageTree) : [] |
| | | const oldIndex = new Map( |
| | | const oldIndex = new Map<string, boolean>( |
| | | serializedExplorerState.map((entry: FolderState) => [entry.path, entry.collapsed]), |
| | | ) |
| | | |
| | |
| | | |
| | | // Get folder paths for state management |
| | | const folderPaths = trie.getFolderPaths() |
| | | currentExplorerState = folderPaths.map((path) => ({ |
| | | path, |
| | | collapsed: oldIndex.get(path) === true, |
| | | })) |
| | | currentExplorerState = folderPaths.map((path) => { |
| | | const previousState = oldIndex.get(path) |
| | | return { |
| | | path, |
| | | collapsed: |
| | | previousState === undefined ? opts.folderDefaultState === "collapsed" : previousState, |
| | | } |
| | | }) |
| | | |
| | | const explorerUl = explorer.querySelector(".explorer-ul") |
| | | if (!explorerUl) continue |