Commit da5fab20 authored by Phil Hughes's avatar Phil Hughes

improve getters code

parent dba40985
......@@ -43,13 +43,11 @@ export const collapseButtonTooltip = state =>
export const hasMergeRequest = state => !!state.currentMergeRequestId;
export const getChangesInFolder = state => path => {
const changedFilesCount = state.changedFiles.filter(
f => f.path.replace(new RegExp(`/${f.name}$`), '') === path,
).length;
const filePatchMatches = f => f.path.replace(new RegExp(`/${f.name}$`), '') === path;
const changedFilesCount = state.changedFiles.filter(f => filePatchMatches(f)).length;
const stagedFilesCount = state.stagedFiles.filter(
f =>
f.path.replace(new RegExp(`/${f.name}$`), '') === path &&
!state.changedFiles.find(changedF => changedF.path === f.path),
filePatchMatches(f) && !state.changedFiles.find(changedFile => changedFile.path === f.path),
).length;
return changedFilesCount + stagedFilesCount;
......
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