Commit dc1f9d06 authored by ioedeveloper's avatar ioedeveloper

expand folder path from event fired

parent 6ddd5f5b
...@@ -139,7 +139,8 @@ const folderAdded = async (folderPath: string) => { ...@@ -139,7 +139,8 @@ const folderAdded = async (folderPath: string) => {
}) })
promise.then((files) => { promise.then((files) => {
dispatch(folderAddedSuccess(path, files)) folderPath = folderPath.replace(/^\/+/, '')
dispatch(folderAddedSuccess(path, folderPath, files))
}).catch((error) => { }).catch((error) => {
console.error(error) console.error(error)
}) })
......
...@@ -62,10 +62,10 @@ export const fileAddedSuccess = (filePath: string) => { ...@@ -62,10 +62,10 @@ export const fileAddedSuccess = (filePath: string) => {
} }
} }
export const folderAddedSuccess = (folderPath: string, fileTree) => { export const folderAddedSuccess = (path: string, folderPath: string, fileTree) => {
return { return {
type: 'FOLDER_ADDED_SUCCESS', type: 'FOLDER_ADDED_SUCCESS',
payload: { path: folderPath, fileTree } payload: { path, folderPath, fileTree }
} }
} }
......
...@@ -286,19 +286,19 @@ export const browserReducer = (state = browserInitialState, action: Action) => { ...@@ -286,19 +286,19 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
} }
case 'FOLDER_ADDED_SUCCESS': { case 'FOLDER_ADDED_SUCCESS': {
const payload = action.payload as { path: string, fileTree } const payload = action.payload as { path: string, folderPath: string, fileTree }
return { return {
...state, ...state,
browser: { browser: {
...state.browser, ...state.browser,
files: state.mode === 'browser' ? fetchDirectoryContent(state, payload) : state.browser.files, files: state.mode === 'browser' ? fetchDirectoryContent(state, payload) : state.browser.files,
expandPath: state.mode === 'browser' ? [...new Set([...state.browser.expandPath, payload.path])] : state.browser.expandPath expandPath: state.mode === 'browser' ? [...new Set([...state.browser.expandPath, payload.folderPath])] : state.browser.expandPath
}, },
localhost: { localhost: {
...state.localhost, ...state.localhost,
files: state.mode === 'localhost' ? fetchDirectoryContent(state, payload) : state.localhost.files, files: state.mode === 'localhost' ? fetchDirectoryContent(state, payload) : state.localhost.files,
expandPath: state.mode === 'localhost' ? [...new Set([...state.localhost.expandPath, payload.path])] : state.localhost.expandPath expandPath: state.mode === 'localhost' ? [...new Set([...state.localhost.expandPath, payload.folderPath])] : state.localhost.expandPath
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment