From 95430ed169a3ba7b59f6736736ca1e8a97143316 Mon Sep 17 00:00:00 2001 From: TaurusXin Date: Sat, 1 Feb 2025 18:57:34 +0800 Subject: [PATCH] fix: eof when save before load --- frontend/src/App.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index bdc4cd4..f9010cc 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -74,6 +74,8 @@ const useStyles = makeStyles({ }, }) +let loaded = false + export const App = () => { const styles = useStyles() @@ -199,17 +201,19 @@ export const App = () => { }) }) Load().then(res => { - console.log(res) setSaveTo(res.save_to as SaveTo) setSavePath(res.path) + loaded = true }) }, []) useEffect(() => { - Save({ - save_to: saveTo, - path: savePath, - }).then(_ => {}) + if (loaded) { + Save({ + save_to: saveTo, + path: savePath, + }).then(_ => {}) + } }, [saveTo, savePath]) OnFileDrop((_x, _y, paths) => {