fix bug
This commit is contained in:
@@ -89,6 +89,9 @@ export function NodeCanvas({
|
||||
|
||||
// Update NPC config when nodes change
|
||||
useEffect(() => {
|
||||
// Skip if no nodes yet
|
||||
if (nodes.length === 0) return;
|
||||
|
||||
const newConfig = { ...npcConfig };
|
||||
|
||||
nodes.forEach((node) => {
|
||||
@@ -146,14 +149,16 @@ export function NodeCanvas({
|
||||
}
|
||||
});
|
||||
|
||||
// Update parent config
|
||||
onConfigChange(newConfig);
|
||||
|
||||
// Update output node preview
|
||||
// Update output node preview with the new config
|
||||
// Check if output node exists and if its preview data needs updating
|
||||
const outputNode = nodes.find(n => n.data.type === 'output');
|
||||
if (outputNode) {
|
||||
if (outputNode && JSON.stringify(outputNode.data.previewData) !== JSON.stringify(newConfig)) {
|
||||
setNodes((nds) =>
|
||||
nds.map((node) =>
|
||||
node.id === outputNode.id
|
||||
node.data.type === 'output'
|
||||
? { ...node, data: { ...node.data, previewData: newConfig } }
|
||||
: node
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user