Changes to only make the Prompt Check run once

This commit is contained in:
Lucas Oliveira 2023-06-29 11:30:00 -03:00
commit 1be3de50c5

View file

@ -29,16 +29,14 @@ export default function PromptAreaComponent({
}, [disabled, onChange]); }, [disabled, onChange]);
useEffect(() => { useEffect(() => {
if (value !== "") { // only executed once if (value !== "" && myValue !== value && reactFlowInstance) { // only executed once
setMyValue(value); setMyValue(value);
postValidatePrompt(value, nodeClass) postValidatePrompt(value, nodeClass)
.then((apiReturn) => { .then((apiReturn) => {
if (apiReturn.data) { if (apiReturn.data) {
setNodeClass(apiReturn.data.frontend_node); setNodeClass(apiReturn.data.frontend_node);
if(reactFlowInstance){ // need to update reactFlowInstance to re-render the nodes.
// need to update reactFlowInstance to re-render the nodes. reactFlowInstance.setEdges(_.cloneDeep(reactFlowInstance.getEdges()));
reactFlowInstance.setEdges(_.cloneDeep(reactFlowInstance.getEdges()));
}
} }
}) })
.catch((error) => {}); .catch((error) => {});