fix(flowsContext.tsx): remove console.log statement used for debugging

fix(EditNodeModal/index.tsx): fix issue with useRef not updating properly by assigning a new object to myData.current
This commit is contained in:
cristhianzl 2023-11-22 21:57:10 -03:00
commit c1fa3c49ab
2 changed files with 14 additions and 4 deletions

View file

@ -600,6 +600,8 @@ export function FlowsProvider({ children }: { children: ReactNode }) {
} }
async function saveFlow(newFlow: FlowType, silent?: boolean) { async function saveFlow(newFlow: FlowType, silent?: boolean) {
console.log(newFlow);
if (newFlow?.data?.nodes?.length === 0) return; if (newFlow?.data?.nodes?.length === 0) return;
try { try {
// updates flow in db // updates flow in db
@ -613,10 +615,14 @@ export function FlowsProvider({ children }: { children: ReactNode }) {
const newFlows = [...prevState]; const newFlows = [...prevState];
const index = newFlows.findIndex((flow) => flow.id === newFlow.id); const index = newFlows.findIndex((flow) => flow.id === newFlow.id);
if (index !== -1) { if (index !== -1) {
newFlows[index].description = newFlow.description ?? ""; newFlows[index] = {
newFlows[index].data = newFlow.data; ...newFlows[index],
newFlows[index].name = newFlow.name; description: updatedFlow.description,
data: updatedFlow.data,
name: updatedFlow.name,
};
} }
return newFlows; return newFlows;
}); });
//update tabs state //update tabs state

View file

@ -57,7 +57,7 @@ const EditNodeModal = forwardRef(
) => { ) => {
const updateNodeInternals = useUpdateNodeInternals(); const updateNodeInternals = useUpdateNodeInternals();
const myData = useRef(data); let myData = useRef(data);
const { setTabsState, tabId } = useContext(FlowsContext); const { setTabsState, tabId } = useContext(FlowsContext);
const { reactFlowInstance } = useContext(typesContext); const { reactFlowInstance } = useContext(typesContext);
@ -69,6 +69,10 @@ const EditNodeModal = forwardRef(
function changeAdvanced(n) { function changeAdvanced(n) {
myData.current.node!.template[n].advanced = myData.current.node!.template[n].advanced =
!myData.current.node!.template[n].advanced; !myData.current.node!.template[n].advanced;
myData.current = {
...myData.current,
};
setAdv(!adv); setAdv(!adv);
} }