🐛 fix(ApiModal/index.tsx): fix conditional check for empty nodes array in useEffect hook

 feat(ApiModal/index.tsx): add startTweaks function to initialize tweaks when nodes array is not empty
This commit is contained in:
Cristhian Zanforlin Lousa 2023-07-14 11:02:55 -03:00
commit dde4ed07ef

View file

@ -107,6 +107,33 @@ const ApiModal = forwardRef(
},
];
useEffect(() => {
if(flow["data"]["nodes"].length == 0){
tweak.current = [];
setTweak(tweak.current);
}
else{
if (tweak.current.length > 0) {
tweak.current = getTweak;
} else {
startTweaks();
}
}
}, [flow["data"]["nodes"]]);
function startTweaks() {
const t = buildTweaks(flow);
Object.keys(t).length == 0 ? tweak.current = [] : tweak?.current?.push(t);
setTweak(tweak.current);
}
useEffect(() => {
filterNodes();
}, []);