Skip to content

Commit

Permalink
fix: added folder-check to initial folder
Browse files Browse the repository at this point in the history
  • Loading branch information
olensmar committed Sep 1, 2021
1 parent 2b45b96 commit c5b22b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/organisms/FileTreePane/FileTreePane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {setRootFolder} from '@redux/thunks/setRootFolder';
import {ipcRenderer} from 'electron';
import FileExplorer from '@atoms/FileExplorer';
import {useFileExplorer} from '@hooks/useFileExplorer';
import fs from 'fs';

interface TreeNode {
key: string;
Expand Down Expand Up @@ -331,7 +332,7 @@ const FileTreePane = () => {
useEffect(() => {
ipcRenderer.on('executed-from', (_, data) => {
const folder = data.path || (loadLastFolderOnStartup && recentFolders.length > 0 ? recentFolders[0] : undefined);
if (folder) {
if (folder && fs.statSync(folder)?.isDirectory()) {
setFolder(folder);
shouldExpandAllNodes.current = true;
setAutoExpandParent(true);
Expand Down
2 changes: 1 addition & 1 deletion src/redux/thunks/setRootFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function updateRecentFolders(thunkAPI: any, rootFolder: string) {
}

// remove entries that don't exist anymore
folders = folders.filter(e => fs.statSync(e) !== undefined);
folders = folders.filter(e => fs.statSync(e)?.isDirectory());
folders.unshift(rootFolder);

electronStore.set('appConfig.recentFolders', folders);
Expand Down

0 comments on commit c5b22b6

Please sign in to comment.