🐛 fix(PageComponent/index.tsx): add timer to automatically save flow every 30 seconds to prevent data loss
This commit is contained in:
parent
a0c4da7d76
commit
230a8b3826
1 changed files with 23 additions and 0 deletions
|
|
@ -160,6 +160,29 @@ export default function Page({
|
|||
setExtraNavigation({ title: "Components" });
|
||||
}, [setExtraComponent, setExtraNavigation]);
|
||||
|
||||
const [seconds, setSeconds] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setSeconds((prevSeconds) => {
|
||||
console.log(prevSeconds);
|
||||
|
||||
let updatedSeconds = prevSeconds + 1;
|
||||
|
||||
if (updatedSeconds % 30 === 0) {
|
||||
saveFlow(flow);
|
||||
updatedSeconds = 0;
|
||||
}
|
||||
|
||||
return updatedSeconds;
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const onEdgesChangeMod = useCallback(
|
||||
(change: EdgeChange[]) => {
|
||||
onEdgesChange(change);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue