Refactor descendant context check in Flowchart activity.

Replaced usage of `GetDescendents` with `Children` property for better clarity and efficiency when checking running activity instances. This simplifies the logic and aligns with the existing structure of activity context handling.
This commit is contained in:
Sipke Schoorstra 2025-01-20 18:07:14 +01:00
parent 7e058ddf15
commit a49bf0c05f

View file

@ -96,8 +96,8 @@ public class Flowchart : Container
{
var workflowExecutionContext = context.WorkflowExecutionContext;
var activityIds = Activities.Select(x => x.Id).ToList();
var descendantContexts = context.GetDescendents().Where(x => x.ParentActivityExecutionContext == context);
var hasRunningActivityInstances = descendantContexts.Where(x => activityIds.Contains(x.Activity.Id)).Any(x => x.Status == ActivityStatus.Running);
var children = context.Children;
var hasRunningActivityInstances = children.Where(x => activityIds.Contains(x.Activity.Id)).Any(x => x.Status == ActivityStatus.Running);
var hasPendingWork = workflowExecutionContext.Scheduler.List().Any(workItem =>
{