From b7b7ff5434d8a0e19d9f7dd8a649973719eadf79 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Thu, 28 Dec 2023 08:08:16 +0100 Subject: [PATCH] sorting --- libs/remix-ui/workspace/src/lib/reducers/workspace.ts | 10 +++------- libs/remix-ui/workspace/src/lib/utils/index.ts | 9 +++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index 3926daf5ee..890f53b08d 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -184,7 +184,7 @@ export const browserReducer = (state = browserInitialState, action: Actions) => case 'FETCH_DIRECTORY_SUCCESS': { const payload = action.payload - console.log('make a flat tree', payload) + console.log('FETCH_DIRECTORY_SUCCESS', payload) const startTime = new Date().getTime() const fd = fetchDirectoryContent(state, payload) const endTime = new Date().getTime() @@ -255,16 +255,11 @@ export const browserReducer = (state = browserInitialState, action: Actions) => case 'FETCH_WORKSPACE_DIRECTORY_SUCCESS': { const payload = action.payload if(state.mode === 'browser'){ - console.log('make a flat tree', payload) + console.log('FETCH_WORKSPACE_DIRECTORY_SUCCESS', payload) } const startTime = new Date().getTime() const fd = fetchWorkspaceDirectoryContent(state, payload) const endTime = new Date().getTime() - - console.log(fd[payload.path]) - const sortedKeys = fileKeySort(fd[payload.path]) - console.log('sortedKeys', sortedKeys) - console.log('fetchDirectoryContent tree', endTime - startTime, fd) return { @@ -957,6 +952,7 @@ const fetchDirectoryContent = ( return state.mode === 'browser' ? state.browser.files : state[state.mode].files + fileKeySort(payload.fileTree) if (state.mode === 'browser') { if (payload.path === ROOT_PATH) { let files = normalize(payload.fileTree, ROOT_PATH, payload.type) diff --git a/libs/remix-ui/workspace/src/lib/utils/index.ts b/libs/remix-ui/workspace/src/lib/utils/index.ts index 9a802d18a9..4cbe68ea13 100644 --- a/libs/remix-ui/workspace/src/lib/utils/index.ts +++ b/libs/remix-ui/workspace/src/lib/utils/index.ts @@ -125,18 +125,19 @@ export const contextMenuActions: MenuItems = [{ }] export const fileKeySort = (children: any): string[] => { - const directories = Object.keys(children).filter((key: string) => children[key].isDirectory && children[key].name !== '') + const directories = Object.keys(children).filter((key: string) => children[key].isDirectory) // sort case insensitive directories.sort((a: string, b: string) => a.toLowerCase().localeCompare(b.toLowerCase())) - const fileKeys = Object.keys(children).filter((key: string) => !children[key].isDirectory && children[key].name !== '') + const fileKeys = Object.keys(children).filter((key: string) => !children[key].isDirectory) // sort case insensitive fileKeys.sort((a: string, b: string) => a.toLowerCase().localeCompare(b.toLowerCase())) // find the children with a blank name - const blankChildren = Object.keys(children).filter((key: string) => children[key].name === '') + //const blankChildren = Object.keys(children).filter((key: string) => children[key].name === '') - const keys = [...directories, ...fileKeys, ...blankChildren] + const keys = [...directories, ...fileKeys] + console.log('sorted keys', keys) return keys }