Commit dbafcc06 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Removed param mutation for removeChildFilesOfTree

parent 636b2425
...@@ -40,12 +40,11 @@ export default class RepoSidebar { ...@@ -40,12 +40,11 @@ export default class RepoSidebar {
}); });
}, },
linkClicked(file) { linkClicked(clickedFile) {
let url = ''; let url = '';
let file = clickedFile;
if (typeof file === 'object') { if (typeof file === 'object') {
if (file.type === 'tree' && file.opened) { if (file.type === 'tree' && file.opened) file = Store.removeChildFilesOfTree(file);
Store.removeChildFilesOfTree(file);
}
url = file.url; url = file.url;
Service.url = url; Service.url = url;
Helper.getContent(file); Helper.getContent(file);
......
...@@ -95,20 +95,22 @@ const RepoStore = { ...@@ -95,20 +95,22 @@ const RepoStore = {
RepoStore.activeFileLabel = 'Display source'; RepoStore.activeFileLabel = 'Display source';
}, },
/* eslint-disable no-param-reassign */
removeChildFilesOfTree(tree) { removeChildFilesOfTree(tree) {
let foundTree = false; let foundTree = false;
const newTree = tree;
RepoStore.files = RepoStore.files.filter((file) => { RepoStore.files = RepoStore.files.filter((file) => {
if (file.url === tree.url) foundTree = true; if (file.url === newTree.url) foundTree = true;
if (foundTree) return file.level <= tree.level; if (foundTree) return file.level <= newTree.level;
return true; return true;
}); });
tree.opened = false; newTree.opened = false;
tree.icon = 'fa-folder'; newTree.icon = 'fa-folder';
return newTree;
}, },
/* eslint-enable no-param-reassign */
removeFromOpenedFiles(file) { removeFromOpenedFiles(file) {
if (file.type === 'tree') return; if (file.type === 'tree') return;
......
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