Commit 99dc4430 authored by Phil Hughes's avatar Phil Hughes

improve performance slightly

still has a massive bottleneck somewhere

[ci skip]
parent ea109251
......@@ -5,10 +5,8 @@ import service from '../../services';
import * as types from '../mutation_types';
import router from '../../ide_router';
import {
setPageTitle,
findEntry,
createTemp,
createOrMergeEntry,
} from '../utils';
import FilesDecoratorWorker from '../workers/files_decorator_worker';
......
......@@ -17,26 +17,17 @@ export const addedFiles = state => changedFilesMap(state).filter(f => f.tempFile
export const modifiedFiles = state => changedFilesMap(state).filter(f => !f.tempFile);
export const treeList = (state) => {
const tree = state.trees['root/testing-123/master'];
const tree = state.trees[`${state.currentProjectId}/master`];
if (!tree) return [];
const map = (arr) => {
if (!arr.tree.length) return [];
return sortTree(arr.tree.reduce((acc, key) => {
const entity = state.entries[key];
if (entity) {
return acc.concat({
...entity,
tree: map(entity),
});
}
return acc;
}, []));
};
const map = arr => sortTree(arr.tree.map((key) => {
const entity = state.entries[key];
return {
...entity,
tree: !arr.tree.length ? [] : map(entity),
};
}));
return map(tree);
};
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