mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
Fix incorrect id resolution in image preview store (#5357)
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
import { LGraphNode, SubgraphNode } from '@/lib/litegraph/src/litegraph'
|
import {
|
||||||
|
LGraphNode,
|
||||||
|
Subgraph,
|
||||||
|
SubgraphNode
|
||||||
|
} from '@/lib/litegraph/src/litegraph'
|
||||||
import {
|
import {
|
||||||
ExecutedWsMessage,
|
ExecutedWsMessage,
|
||||||
ResultItem,
|
ResultItem,
|
||||||
@@ -136,17 +140,22 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {
|
|||||||
) {
|
) {
|
||||||
if (!filenames || !node) return
|
if (!filenames || !node) return
|
||||||
|
|
||||||
|
const locatorId =
|
||||||
|
node.graph instanceof Subgraph
|
||||||
|
? nodeIdToNodeLocatorId(node.id, node.graph ?? undefined)
|
||||||
|
: `${node.id}`
|
||||||
|
if (!locatorId) return
|
||||||
if (typeof filenames === 'string') {
|
if (typeof filenames === 'string') {
|
||||||
setNodeOutputsByNodeId(
|
setOutputsByLocatorId(
|
||||||
node.id,
|
locatorId,
|
||||||
createOutputs([filenames], folder, isAnimated)
|
createOutputs([filenames], folder, isAnimated)
|
||||||
)
|
)
|
||||||
} else if (!Array.isArray(filenames)) {
|
} else if (!Array.isArray(filenames)) {
|
||||||
setNodeOutputsByNodeId(node.id, filenames)
|
setOutputsByLocatorId(locatorId, filenames)
|
||||||
} else {
|
} else {
|
||||||
const resultItems = createOutputs(filenames, folder, isAnimated)
|
const resultItems = createOutputs(filenames, folder, isAnimated)
|
||||||
if (!resultItems?.images?.length) return
|
if (!resultItems?.images?.length) return
|
||||||
setNodeOutputsByNodeId(node.id, resultItems)
|
setOutputsByLocatorId(locatorId, resultItems)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,26 +179,6 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {
|
|||||||
setOutputsByLocatorId(nodeLocatorId, outputs, options)
|
setOutputsByLocatorId(nodeLocatorId, outputs, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set node outputs by node ID.
|
|
||||||
* Uses the current graph context to create the appropriate NodeLocatorId.
|
|
||||||
*
|
|
||||||
* @param nodeId - The node ID
|
|
||||||
* @param outputs - The outputs to store
|
|
||||||
* @param options - Options for setting outputs
|
|
||||||
* @param options.merge - If true, merge with existing outputs (arrays are concatenated)
|
|
||||||
*/
|
|
||||||
function setNodeOutputsByNodeId(
|
|
||||||
nodeId: string | number,
|
|
||||||
outputs: ExecutedWsMessage['output'] | ResultItem,
|
|
||||||
options: SetOutputOptions = {}
|
|
||||||
) {
|
|
||||||
const nodeLocatorId = nodeIdToNodeLocatorId(nodeId)
|
|
||||||
if (!nodeLocatorId) return
|
|
||||||
|
|
||||||
setOutputsByLocatorId(nodeLocatorId, outputs, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set node preview images by execution ID (hierarchical ID from backend).
|
* Set node preview images by execution ID (hierarchical ID from backend).
|
||||||
* Converts the execution ID to a NodeLocatorId before storing.
|
* Converts the execution ID to a NodeLocatorId before storing.
|
||||||
@@ -288,7 +277,6 @@ export const useNodeOutputStore = defineStore('nodeOutput', () => {
|
|||||||
getNodePreviews,
|
getNodePreviews,
|
||||||
setNodeOutputs,
|
setNodeOutputs,
|
||||||
setNodeOutputsByExecutionId,
|
setNodeOutputsByExecutionId,
|
||||||
setNodeOutputsByNodeId,
|
|
||||||
setNodePreviewsByExecutionId,
|
setNodePreviewsByExecutionId,
|
||||||
setNodePreviewsByNodeId,
|
setNodePreviewsByNodeId,
|
||||||
revokePreviewsByExecutionId,
|
revokePreviewsByExecutionId,
|
||||||
|
|||||||
Reference in New Issue
Block a user