🐛 fix(ApiModal/index.tsx): fix bug where tweak.current was not being properly reset when getTweak, tweak.current, and flow["data"]["nodes"] were all empty

 feat(ApiModal/index.tsx): add useEffect dependency on flow["data"]["nodes"] to trigger filterNodes function when nodes data changes
This commit is contained in:
Cristhian Zanforlin Lousa 2023-07-14 16:06:55 -03:00
commit ee4c465aba

View file

@ -112,13 +112,19 @@ const ApiModal = forwardRef(
];
useEffect(() => {
filterNodes();
if(getTweak.length == 0){
const t = buildTweaks(flow);
tweak?.current?.push(t);
if(getTweak.length == 0 && tweak?.current.length == 0 && flow["data"]["nodes"].length == 0){
tweak.current = [];
}
else {
tweak.current = [];
const t = buildTweaks(flow);
tweak.current.push(t);
}
filterNodes();
if (Object.keys(tweaksCode).length > 0) {
tabs.push({
name: "Tweaks",
@ -128,7 +134,7 @@ const ApiModal = forwardRef(
});
}
}, [closePopUp]);
}, [flow["data"]["nodes"]]);
function filterNodes() {