Skip to content

Commit

Permalink
cleanup ...
Browse files Browse the repository at this point in the history
  • Loading branch information
bomsy authored and Johnny Khalil committed Oct 13, 2017
1 parent 15f7df9 commit 41efe91
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/components/shared/ManagedTree.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @flow
import React, { createFactory, Component } from "react";
import { nodeHasChildren } from "../../utils/sources-tree";
import "./ManagedTree.css";

import { Tree as _Tree } from "devtools-components";
Expand Down Expand Up @@ -69,31 +68,32 @@ class ManagedTree extends Component {
}
}

setExpanded = (item: Item, isExpanded: boolean, isRecursive: boolean) => {
setExpanded = (
item: Item,
isExpanded: boolean,
shouldIncludeChildren: boolean
) => {
const expandItem = i => {
const path = this.props.getPath(i);
if (isExpanded) {
expanded.add(path);
} else {
expanded.delete(path);
}
};
const expanded = this.state.expanded;
let itemPath = this.props.getPath(item);
if (isExpanded) {
expanded.add(itemPath);
} else {
expanded.delete(itemPath);
}
if (isRecursive) {
let children = null;
expandItem(item);

if (shouldIncludeChildren) {
let parents = [item];
while (parents.length) {
children = [];
const children = [];
for (const parent of parents) {
if (!nodeHasChildren(parent)) {
continue;
}
for (const child of parent.contents) {
itemPath = this.props.getPath(child);
if (isExpanded) {
expanded.add(itemPath);
} else {
expanded.delete(itemPath);
if (parent.contents && parent.contents.length) {
for (const child of parent.contents) {
expandItem(child);
children.push(child);
}
children.push(child);
}
}
parents = children;
Expand Down

0 comments on commit 41efe91

Please sign in to comment.