From 29ce2eb9408efd14d232456607d18d5adbd5d6eb Mon Sep 17 00:00:00 2001 From: David Disu Date: Tue, 30 Aug 2022 14:28:16 +0100 Subject: [PATCH] Resolve localhost files --- .../workspace/src/lib/reducers/workspace.ts | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index b29fa6a0ef..af20d18fa2 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -756,14 +756,11 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s return files } } else { - if (payload.path === '/') { - const files = normalize(payload.fileTree, payload.path, payload.type) - return { [state.mode]: files } - } else if (payload.path === state.mode) { - let files = normalize(payload.fileTree, payload.path, payload.type) - files = _.merge(files, state[state.mode].files[state.mode]) + if (payload.path === ROOT_PATH) { + let files = normalize(payload.fileTree, ROOT_PATH, payload.type) + files = _.merge(files, state.localhost.files[ROOT_PATH]) if (deletePath) delete files[deletePath] - return { [state.mode]: files } + return { [ROOT_PATH]: files } } else { let files = state.localhost.files const _path = splitPath(state, payload.path) @@ -788,13 +785,9 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s } const fetchWorkspaceDirectoryContent = (state: BrowserState, payload: { fileTree, path: string }): { [x: string]: Record } => { - if (state.mode === 'browser') { - const files = normalize(payload.fileTree, ROOT_PATH) + const files = normalize(payload.fileTree, ROOT_PATH) - return { [ROOT_PATH]: files } - } else { - return fetchDirectoryContent(state, payload) - } + return { [ROOT_PATH]: files } } const normalize = (filesList, directory?: string, newInputType?: 'folder' | 'file'): Record => { @@ -847,7 +840,7 @@ const normalize = (filesList, directory?: string, newInputType?: 'folder' | 'fil } const splitPath = (state: BrowserState, path: string): string[] | string => { - const root = state.mode === 'browser' ? ROOT_PATH : 'localhost' + const root = ROOT_PATH const pathArr: string[] = (path || '').split('/').filter(value => value) if (pathArr[0] !== root) pathArr.unshift(root)