Skip to content
Snippets Groups Projects
Unverified Commit cc04a18d authored by Phil Hughes's avatar Phil Hughes
Browse files

improve performance of deleting

parent 3f4aaea2
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Loading
Loading
@@ -187,24 +187,32 @@ export const openNewEntryModal = ({ commit }, { type, path = '' }) => {
 
export const deleteEntry = ({ commit, dispatch, state }, path) => {
const entry = state.entries[path];
dispatch('burstUnusedSeal');
dispatch('closeFile', entry);
if (state.unusedSeal) dispatch('burstUnusedSeal');
if (entry.opened) dispatch('closeFile', entry);
 
if (entry.type === 'tree') {
entry.tree.forEach(f => dispatch('deleteEntry', f.path));
}
 
commit(types.DELETE_ENTRY, path);
if (entry.parentPath && state.entries[entry.parentPath].tree.length === 0) {
dispatch('deleteEntry', entry.parentPath);
}
};
 
export const resetOpenFiles = ({ commit }) => commit(types.RESET_OPEN_FILES);
 
export const renameEntry = ({ dispatch, commit, state }, { path, name, entryPath = null }) => {
const entry = state.entries[entryPath || path];
commit(types.RENAME_ENTRY, { path, name, entryPath });
 
state.entries[entryPath || path].tree.forEach(f =>
dispatch('renameEntry', { path, name, entryPath: f.path }),
);
if (entry.type === 'tree') {
state.entries[entryPath || path].tree.forEach(f =>
dispatch('renameEntry', { path, name, entryPath: f.path }),
);
}
 
if (!entryPath) {
dispatch('deleteEntry', path);
Loading
Loading
Loading
Loading
@@ -67,9 +67,9 @@ export const someUncommitedChanges = state =>
!!(state.changedFiles.length || state.stagedFiles.length);
 
export const getChangesInFolder = state => path => {
const changedFilesCount = state.changedFiles.filter(f => filePathMatches(f, path)).length;
const changedFilesCount = state.changedFiles.filter(f => filePathMatches(f.path, path)).length;
const stagedFilesCount = state.stagedFiles.filter(
f => filePathMatches(f, path) && !getChangedFile(state)(f.path),
f => filePathMatches(f.path, path) && !getChangedFile(state)(f.path),
).length;
 
return changedFilesCount + stagedFilesCount;
Loading
Loading
Loading
Loading
@@ -198,7 +198,8 @@ export default {
: state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
 
entry.deleted = true;
parent.tree = parent.tree.filter(f => f.path !== entry.path);
parent.tree.splice(parent.tree.findIndex(f => f.path === entry.path), 1);
 
if (entry.type === 'blob') {
state.changedFiles = state.changedFiles.concat(entry);
Loading
Loading
Loading
Loading
@@ -172,8 +172,7 @@ export const sortTree = sortedTree =>
)
.sort(sortTreesByTypeAndName);
 
export const filePathMatches = (f, path) =>
f.path.replace(new RegExp(`${f.name}$`), '').indexOf(`${path}/`) === 0;
export const filePathMatches = (filePath, path) => filePath.indexOf(`${path}/`) === 0;
 
export const getChangesCountForFiles = (files, path) =>
files.filter(f => filePathMatches(f, path)).length;
files.filter(f => filePathMatches(f.path, path)).length;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment