public static V1WorkflowActivityCollectionState OnAddV1WorkflowInstance(V1WorkflowActivityCollectionState state, AddV1WorkflowInstance action) { var activities = (action.WorkflowInstance.Activities ?? new Collection <V1WorkflowActivity>()).AsEnumerable(); var activityIds = activities.Select(activity => activity.Id).ToList(); activities = activities.Concat(state.Where(activity => !activityIds.Contains(activity.Id))); return(new(activities)); }
public static V1WorkflowActivityCollectionState OnGetWorkflowsFromApiSucceeded(V1WorkflowActivityCollectionState state, SetV1WorkflowInstanceCollection action) { var activities = action.WorkflowInstances.SelectMany(instance => instance.Activities ?? new Collection <V1WorkflowActivity>()); var activityIds = activities.Select(activity => activity.Id).ToList(); activities = activities.Concat(state.Where(activity => !activityIds.Contains(activity.Id))); return(new(activities)); }