Skip to content

Commit

Permalink
[TS] Add null check in paste handler (#2722)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfiltered authored Feb 25, 2025
1 parent 417a089 commit 51c16a4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/composables/usePaste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ export const usePaste = () => {
if (!imageNode) {
// No image node selected: add a new one
const newNode = LiteGraph.createNode('LoadImage')
newNode.pos = [canvas.graph_mouse[0], canvas.graph_mouse[1]]
if (newNode) imageNode = graph?.add(newNode) ?? null
if (newNode) {
newNode.pos = [canvas.graph_mouse[0], canvas.graph_mouse[1]]
imageNode = graph?.add(newNode) ?? null
}
graph?.change()
}
pasteItemOnNode(items, imageNode)
Expand All @@ -83,8 +85,10 @@ export const usePaste = () => {
if (!audioNode) {
// No audio node selected: add a new one
const newNode = LiteGraph.createNode('LoadAudio')
newNode.pos = [canvas.graph_mouse[0], canvas.graph_mouse[1]]
if (newNode) audioNode = graph?.add(newNode) ?? null
if (newNode) {
newNode.pos = [canvas.graph_mouse[0], canvas.graph_mouse[1]]
audioNode = graph?.add(newNode) ?? null
}
graph?.change()
}
pasteItemOnNode(items, audioNode)
Expand Down

0 comments on commit 51c16a4

Please sign in to comment.