Skip to content

Commit

Permalink
Simplify if expression
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Mäder <[email protected]>
  • Loading branch information
tsmaeder committed Aug 23, 2023
1 parent f862476 commit 83b844d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,10 @@ export class PluginTree extends TreeImpl {

override markAsChecked(node: Mutable<TreeNode>, checked: boolean): void {
function findParentsToChange(child: TreeNode, nodes: TreeNode[]): void {
if (child.parent) {
if (child.parent.checkboxInfo !== undefined && child.parent.checkboxInfo.checked !== checked) {
if (!checked || child.parent.children.every(candidate => candidate.checkboxInfo?.checked || candidate.checkboxInfo === undefined || candidate === child)) {
nodes.push(child.parent);
findParentsToChange(child.parent, nodes);
}
}
if ((child.parent?.checkboxInfo !== undefined && child.parent.checkboxInfo.checked !== checked) &&
(!checked || !child.parent.children.some(candidate => candidate !== child && candidate.checkboxInfo?.checked === false))) {
nodes.push(child.parent);
findParentsToChange(child.parent, nodes);
}
}

Expand Down

0 comments on commit 83b844d

Please sign in to comment.