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