From e07bf43c5440a5888b148eb14d7705ae171976a5 Mon Sep 17 00:00:00 2001 From: greyguy21 <62389546+greyguy21@users.noreply.github.com> Date: Thu, 24 Aug 2023 14:06:06 +0800 Subject: [PATCH] Fix blank screen after scan complete and ensure default values are present in userData file (#22) * Ensure mandatory fields are set in userData.txt * Fix blank screen after scan --- public/electron/userDataManager.js | 17 +++++++++++++++++ src/MainWindow/ResultPage/index.jsx | 5 +++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/public/electron/userDataManager.js b/public/electron/userDataManager.js index fd266d00..1b396448 100644 --- a/public/electron/userDataManager.js +++ b/public/electron/userDataManager.js @@ -37,8 +37,25 @@ const init = async () => { exportDir: defaultExportDir }; fs.writeFileSync(userDataFilePath, JSON.stringify(defaultSettings)); + } else { + // check if mandatory fields are set + const userData = JSON.parse(fs.readFileSync(userDataFilePath)); + if (!userData.exportDir) { + userData.exportDir = defaultExportDir; + } + if (!userData.name) { + userData.name = ""; + } + if (!userData.email) { + userData.email = ""; + } + if (!userData.browser) { + userData.browser = proxy ? "edge" : "chrome"; + } + fs.writeFileSync(userDataFilePath, JSON.stringify(userData)); } + ipcMain.handle("getUserData", (_event) => { const data = readUserDataFromFile(); return data; diff --git a/src/MainWindow/ResultPage/index.jsx b/src/MainWindow/ResultPage/index.jsx index 4122e510..2cc481ee 100644 --- a/src/MainWindow/ResultPage/index.jsx +++ b/src/MainWindow/ResultPage/index.jsx @@ -24,8 +24,9 @@ const ResultPage = ({ completedScanId: scanId }) => { const [showCustomFlowReplayButton, setShowCustomFlowReplayButton] = useState(false); useEffect(() => { - console.log('is custom flow: ', state); - setShowCustomFlowReplayButton(state.isCustomScan); + if (state && state.isCustomScan) { + setShowCustomFlowReplayButton(state.isCustomScan); + } }, []) useEffect(() => {