From d95a040477bae7ee1ab076e9832e5e8cba8702bf Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Tue, 6 Jul 2021 16:09:15 +0200 Subject: [PATCH] Update fileSystem.ts --- .../src/lib/reducers/fileSystem.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libs/remix-ui/file-explorer/src/lib/reducers/fileSystem.ts b/libs/remix-ui/file-explorer/src/lib/reducers/fileSystem.ts index ac00815802..7646e03036 100644 --- a/libs/remix-ui/file-explorer/src/lib/reducers/fileSystem.ts +++ b/libs/remix-ui/file-explorer/src/lib/reducers/fileSystem.ts @@ -266,15 +266,16 @@ const removePath = (root, path: string, pathName, files) => { return Array.isArray(cur) ? [...acc, ...cur] : [...acc, cur] }, []) const prevFiles = _.get(files, _path) - - prevFiles && prevFiles.child && prevFiles.child[pathName] && delete prevFiles.child[pathName] - files = _.set(files, _path, { - isDirectory: true, - path, - name: extractNameFromKey(path).indexOf('gist-') === 0 ? extractNameFromKey(path).split('-')[1] : extractNameFromKey(path), - type: extractNameFromKey(path).indexOf('gist-') === 0 ? 'gist' : 'folder', - child: prevFiles ? prevFiles.child : {} - }) + if (prevFiles) { + prevFiles.child && prevFiles.child[pathName] && delete prevFiles.child[pathName] + files = _.set(files, _path, { + isDirectory: true, + path, + name: extractNameFromKey(path).indexOf('gist-') === 0 ? extractNameFromKey(path).split('-')[1] : extractNameFromKey(path), + type: extractNameFromKey(path).indexOf('gist-') === 0 ? 'gist' : 'folder', + child: prevFiles ? prevFiles.child : {} + }) + } return files }