fix(ui): check for valid controlnets before adding to graph

This commit is contained in:
psychedelicious 2023-06-12 15:35:21 +10:00
parent af42d7d347
commit 36f72b5a49

View File

@ -1,5 +1,5 @@
import { RootState } from 'app/store/store';
import { forEach, size } from 'lodash-es';
import { filter, forEach, size } from 'lodash-es';
import { CollectInvocation, ControlNetInvocation } from 'services/api';
import { NonNullableGraph } from '../types/types';
@ -12,10 +12,13 @@ export const addControlNetToLinearGraph = (
): void => {
const { isEnabled: isControlNetEnabled, controlNets } = state.controlNet;
const controlNetCount = size(controlNets);
const validControlNets = filter(
controlNets,
(c) => c.isEnabled && Boolean(c.processedControlImage)
);
// Add ControlNet
if (isControlNetEnabled && controlNetCount > 0) {
if (isControlNetEnabled && validControlNets.length > 0) {
if (size(controlNets) > 1) {
const controlNetIterateNode: CollectInvocation = {
id: CONTROL_NET_COLLECT,