Skip to content

Commit a69b241

Browse files
authored
Fix incorrect id resolution in image preview store (#5357)
1 parent 1ae67dd commit a69b241

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

src/stores/imagePreviewStore.ts

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { defineStore } from 'pinia'
22

3-
import { LGraphNode, SubgraphNode } from '@/lib/litegraph/src/litegraph'
3+
import {
4+
LGraphNode,
5+
Subgraph,
6+
SubgraphNode
7+
} from '@/lib/litegraph/src/litegraph'
48
import {
59
ExecutedWsMessage,
610
ResultItem,
@@ -136,17 +140,22 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {
136140
) {
137141
if (!filenames || !node) return
138142

143+
const locatorId =
144+
node.graph instanceof Subgraph
145+
? nodeIdToNodeLocatorId(node.id, node.graph ?? undefined)
146+
: `${node.id}`
147+
if (!locatorId) return
139148
if (typeof filenames === 'string') {
140-
setNodeOutputsByNodeId(
141-
node.id,
149+
setOutputsByLocatorId(
150+
locatorId,
142151
createOutputs([filenames], folder, isAnimated)
143152
)
144153
} else if (!Array.isArray(filenames)) {
145-
setNodeOutputsByNodeId(node.id, filenames)
154+
setOutputsByLocatorId(locatorId, filenames)
146155
} else {
147156
const resultItems = createOutputs(filenames, folder, isAnimated)
148157
if (!resultItems?.images?.length) return
149-
setNodeOutputsByNodeId(node.id, resultItems)
158+
setOutputsByLocatorId(locatorId, resultItems)
150159
}
151160
}
152161

@@ -170,26 +179,6 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {
170179
setOutputsByLocatorId(nodeLocatorId, outputs, options)
171180
}
172181

173-
/**
174-
* Set node outputs by node ID.
175-
* Uses the current graph context to create the appropriate NodeLocatorId.
176-
*
177-
* @param nodeId - The node ID
178-
* @param outputs - The outputs to store
179-
* @param options - Options for setting outputs
180-
* @param options.merge - If true, merge with existing outputs (arrays are concatenated)
181-
*/
182-
function setNodeOutputsByNodeId(
183-
nodeId: string | number,
184-
outputs: ExecutedWsMessage['output'] | ResultItem,
185-
options: SetOutputOptions = {}
186-
) {
187-
const nodeLocatorId = nodeIdToNodeLocatorId(nodeId)
188-
if (!nodeLocatorId) return
189-
190-
setOutputsByLocatorId(nodeLocatorId, outputs, options)
191-
}
192-
193182
/**
194183
* Set node preview images by execution ID (hierarchical ID from backend).
195184
* Converts the execution ID to a NodeLocatorId before storing.
@@ -288,7 +277,6 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {
288277
getNodePreviews,
289278
setNodeOutputs,
290279
setNodeOutputsByExecutionId,
291-
setNodeOutputsByNodeId,
292280
setNodePreviewsByExecutionId,
293281
setNodePreviewsByNodeId,
294282
revokePreviewsByExecutionId,

0 commit comments

Comments
 (0)