fix(flowsContext.tsx): remove unnecessary console.log statement
fix(flowsContext.tsx): update saveFlow function to check for empty nodes before saving fix(flowsContext.tsx): update saveFlow function to handle optional description property fix(flowsContext.tsx): update saveFlow function to correctly update flow data in state fix(PageComponent/index.tsx): add missing flows dependency to useEffect hook fix(PageComponent/index.tsx): update saveFlow function to correctly pass flow data to saveFlow function
This commit is contained in:
parent
30cc5723bd
commit
fa7376c118
2 changed files with 11 additions and 10 deletions
|
|
@ -595,14 +595,16 @@ export function FlowsProvider({ children }: { children: ReactNode }) {
|
|||
newFlows[index].data = newFlow.data;
|
||||
newFlows[index].name = newFlow.name;
|
||||
}
|
||||
newFlow = {
|
||||
...newFlow,
|
||||
};
|
||||
return newFlows;
|
||||
});
|
||||
}
|
||||
|
||||
async function saveFlow(newFlow: FlowType, silent?: boolean) {
|
||||
console.log(newFlow);
|
||||
|
||||
if (newFlow?.data?.nodes?.length === 0) return;
|
||||
|
||||
try {
|
||||
// updates flow in db
|
||||
const updatedFlow = await updateFlowInDatabase(newFlow);
|
||||
|
|
@ -615,14 +617,10 @@ export function FlowsProvider({ children }: { children: ReactNode }) {
|
|||
const newFlows = [...prevState];
|
||||
const index = newFlows.findIndex((flow) => flow.id === newFlow.id);
|
||||
if (index !== -1) {
|
||||
newFlows[index] = {
|
||||
...newFlows[index],
|
||||
description: updatedFlow.description,
|
||||
data: updatedFlow.data,
|
||||
name: updatedFlow.name,
|
||||
};
|
||||
newFlows[index].description = newFlow.description ?? "";
|
||||
newFlows[index].data = newFlow.data;
|
||||
newFlows[index].name = newFlow.name;
|
||||
}
|
||||
|
||||
return newFlows;
|
||||
});
|
||||
//update tabs state
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ export default function Page({
|
|||
saveFlow,
|
||||
setTabsState,
|
||||
tabId,
|
||||
flows,
|
||||
} = useContext(FlowsContext);
|
||||
const {
|
||||
types,
|
||||
|
|
@ -182,6 +183,8 @@ export default function Page({
|
|||
const [seconds, setSeconds] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const index = flows.findIndex((flowId) => flowId.id === flow.id);
|
||||
|
||||
const interval = setInterval(() => {
|
||||
setSeconds((prevSeconds) => {
|
||||
let updatedSeconds = prevSeconds + 1;
|
||||
|
|
@ -189,7 +192,7 @@ export default function Page({
|
|||
if (updatedSeconds % 30 === 0) {
|
||||
saveFlow(
|
||||
{
|
||||
...flow!,
|
||||
...flows[index]!,
|
||||
data: reactFlowInstance
|
||||
? reactFlowInstance!.toObject()
|
||||
: flow!.data,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue