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].data = newFlow.data;
|
||||||
newFlows[index].name = newFlow.name;
|
newFlows[index].name = newFlow.name;
|
||||||
}
|
}
|
||||||
|
newFlow = {
|
||||||
|
...newFlow,
|
||||||
|
};
|
||||||
return newFlows;
|
return newFlows;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
const updatedFlow = await updateFlowInDatabase(newFlow);
|
const updatedFlow = await updateFlowInDatabase(newFlow);
|
||||||
|
|
@ -615,14 +617,10 @@ 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] = {
|
newFlows[index].description = newFlow.description ?? "";
|
||||||
...newFlows[index],
|
newFlows[index].data = newFlow.data;
|
||||||
description: updatedFlow.description,
|
newFlows[index].name = newFlow.name;
|
||||||
data: updatedFlow.data,
|
|
||||||
name: updatedFlow.name,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newFlows;
|
return newFlows;
|
||||||
});
|
});
|
||||||
//update tabs state
|
//update tabs state
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ export default function Page({
|
||||||
saveFlow,
|
saveFlow,
|
||||||
setTabsState,
|
setTabsState,
|
||||||
tabId,
|
tabId,
|
||||||
|
flows,
|
||||||
} = useContext(FlowsContext);
|
} = useContext(FlowsContext);
|
||||||
const {
|
const {
|
||||||
types,
|
types,
|
||||||
|
|
@ -182,6 +183,8 @@ export default function Page({
|
||||||
const [seconds, setSeconds] = useState(0);
|
const [seconds, setSeconds] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const index = flows.findIndex((flowId) => flowId.id === flow.id);
|
||||||
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
setSeconds((prevSeconds) => {
|
setSeconds((prevSeconds) => {
|
||||||
let updatedSeconds = prevSeconds + 1;
|
let updatedSeconds = prevSeconds + 1;
|
||||||
|
|
@ -189,7 +192,7 @@ export default function Page({
|
||||||
if (updatedSeconds % 30 === 0) {
|
if (updatedSeconds % 30 === 0) {
|
||||||
saveFlow(
|
saveFlow(
|
||||||
{
|
{
|
||||||
...flow!,
|
...flows[index]!,
|
||||||
data: reactFlowInstance
|
data: reactFlowInstance
|
||||||
? reactFlowInstance!.toObject()
|
? reactFlowInstance!.toObject()
|
||||||
: flow!.data,
|
: flow!.data,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue