Skip to content

Commit

Permalink
Lazy-load branches
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Jan 5, 2025
1 parent d79e30e commit 9d59cec
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ def update(self, node=None):
node = node or self.process_node
super().update(node)
self.tally.value = self._get_tally(node)
self._add_branches(node)
if not self.collapsed:
self._add_branches(node)
branch: TreeNode
for branch in self.branches.children:
branch.update()
Expand Down Expand Up @@ -214,7 +215,8 @@ def _build_header(self, node, level):
self.tally,
]

def _add_branches(self, node):
def _add_branches(self, node=None):
node = node or self.process_node
for child in node.called:
if child.pk in self.pks:
continue
Expand All @@ -231,6 +233,7 @@ def _add_branches(self, node):
level=self.level + 1,
on_inspect=self.on_inspect,
)
branch.update()
self.branches.children += (branch,)
self.pks.add(child.pk)

Expand All @@ -255,6 +258,7 @@ def _toggle_branches(self, _):
if self.collapsed:
self.branches.add_class("open")
self.toggle.icon = "minus"
self._add_branches()
else:
self.branches.remove_class("open")
self.toggle.icon = "plus"
Expand Down

0 comments on commit 9d59cec

Please sign in to comment.