diff --git a/docs/features/applications/README.md b/docs/features/applications/README.md index a0b0496..bd63eff 100644 --- a/docs/features/applications/README.md +++ b/docs/features/applications/README.md @@ -6,11 +6,11 @@ Applications (sometimes shortened to apps) are processes that open a window when ## Table of Contents -- [ Terminal](terminal/README.md) -- [ File Explorer](file-explorer/README.md) -- [ Media Viewer](media-viewer/README.md) -- [ Text Editor](text-editor/README.md) -- [ Settings](settings/README.md) +- [ Terminal](terminal/README.md) +- [ File Explorer](file-explorer/README.md) +- [ Media Viewer](media-viewer/README.md) +- [ Text Editor](text-editor/README.md) +- [ Settings](settings/README.md) ## Common components diff --git a/src/components/applications/file-explorer/FileExplorer.jsx b/src/components/applications/file-explorer/FileExplorer.jsx index e526ff5..9ed4504 100644 --- a/src/components/applications/file-explorer/FileExplorer.jsx +++ b/src/components/applications/file-explorer/FileExplorer.jsx @@ -35,11 +35,14 @@ function FilePreview({ file }) { export function FileExplorer({ startPath }) { const virtualRoot = useVirtualRoot(); const [currentDirectory, setCurrentDirectory] = useState(virtualRoot.navigate(startPath ?? "~")); - const [path, setPath] = useState(currentDirectory.path); + const [path, setPath] = useState(currentDirectory?.path ?? ""); const windowsManager = useWindowsManager(); const [showHidden] = useState(true); const changeDirectory = (path, absolute = false) => { + if (currentDirectory == null) + absolute = true; + const directory = absolute ? virtualRoot.navigate(path) : currentDirectory.navigate(path); console.log(directory); @@ -108,7 +111,7 @@ export function FileExplorer({ startPath }) {
- {currentDirectory.getFiles(showHidden).map((file, index) => + {currentDirectory?.getFiles(showHidden)?.map((file, index) => )} - {currentDirectory.getSubFolders(showHidden).map(({ name }, index) => + {currentDirectory?.getSubFolders(showHidden)?.map(({ name }, index) =>