diff --git a/src/renderer/hooks/useRunNode.ts b/src/renderer/hooks/useRunNode.ts index 8a4c69a9a..68b826990 100644 --- a/src/renderer/hooks/useRunNode.ts +++ b/src/renderer/hooks/useRunNode.ts @@ -2,7 +2,7 @@ import log from 'electron-log'; import { useEffect, useMemo, useRef } from 'react'; import { useContext } from 'use-context-selector'; import { NodeData } from '../../common/common-types'; -import { delay, getInputValues, isStartingNode } from '../../common/util'; +import { delay, getInputValues } from '../../common/util'; import { AlertBoxContext } from '../contexts/AlertBoxContext'; import { BackendContext } from '../contexts/BackendContext'; import { GlobalContext } from '../contexts/GlobalNodeState'; @@ -25,6 +25,8 @@ export const useRunNode = ({ inputData, id, schemaId }: NodeData, shouldRun: boo const schema = schemata.get(schemaId); + const didEverRun = useRef(false); + const inputs = useMemo( () => getInputValues(schema, (inputId) => inputData[inputId] ?? null), [inputData] @@ -43,6 +45,7 @@ export const useRunNode = ({ inputData, id, schemaId }: NodeData, shouldRun: boo lastInputHash.current = inputHash; if (shouldRun) { + didEverRun.current = true; animate([id], false); const result = await backend.runIndividual({ @@ -74,14 +77,8 @@ export const useRunNode = ({ inputData, id, schemaId }: NodeData, shouldRun: boo useEffect(() => { return () => { - // TODO: Change this if we ever make more than starting nodes run - if (isStartingNode(schema)) { - backend - .clearNodeCacheIndividual(id) - .then(() => {}) - .catch((error) => { - log.error(error); - }); + if (didEverRun.current) { + backend.clearNodeCacheIndividual(id).catch((error) => log.error(error)); } }; }, []);