From c9e357384737efb52580c166b080c14fb040db82 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Mon, 24 Feb 2025 21:36:26 +1100 Subject: [PATCH] [TS] Fix nullability `LGraphCanvas.graph` may explicity set to null by litegraph. --- src/composables/useCoreCommands.ts | 2 +- src/composables/usePaste.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/composables/useCoreCommands.ts b/src/composables/useCoreCommands.ts index cb81a474a..5f50f21f7 100644 --- a/src/composables/useCoreCommands.ts +++ b/src/composables/useCoreCommands.ts @@ -337,7 +337,7 @@ export function useCoreCommands(): ComfyCommand[] { 'Comfy.GroupSelectedNodes.Padding' ) group.resizeTo(canvas.selectedItems, padding) - canvas.graph.add(group) + canvas.graph?.add(group) useTitleEditorStore().titleEditorTarget = group } }, diff --git a/src/composables/usePaste.ts b/src/composables/usePaste.ts index 558f77a80..ddc8ac4c2 100644 --- a/src/composables/usePaste.ts +++ b/src/composables/usePaste.ts @@ -66,8 +66,8 @@ export const usePaste = () => { const newNode = LiteGraph.createNode('LoadImage') // @ts-expect-error array to Float32Array newNode.pos = [...canvas.graph_mouse] - imageNode = graph.add(newNode) ?? null - graph.change() + imageNode = graph?.add(newNode) ?? null + graph?.change() } pasteItemOnNode(items, imageNode) return