From 9ff9025aa4b15293779b565cc767837a5e9b0cf9 Mon Sep 17 00:00:00 2001 From: Kyle Micallef Bonnici Date: Mon, 10 Jul 2023 12:52:33 +0200 Subject: [PATCH] Fix/app crash deleting project folder (#53) * Fix app crashing issue * Fix create empty folder --- Changelog.md | 3 ++ .../Profiling/ProfilingProjects/Profiles.tsx | 4 +-- .../useProfilingProjects.tsx | 35 +++++++------------ src/features/nrfutillNpm/csvProcessing.ts | 1 - 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/Changelog.md b/Changelog.md index 9e91072e..c319ae28 100644 --- a/Changelog.md +++ b/Changelog.md @@ -18,6 +18,9 @@ and this project adheres to - `Restart application with verbose logging` button did not restart app - Aborting profiling wizard would not closed dialog when device is disconnected and we are waiting to reconnect +- App crash if profiling project is deleted while app is running +- Empty directory is created if profiling folder is deleted and app is + reopened ## 0.9.0 - 2023-06-27 diff --git a/src/components/Profiling/ProfilingProjects/Profiles.tsx b/src/components/Profiling/ProfilingProjects/Profiles.tsx index 964a1123..45e06f8d 100644 --- a/src/components/Profiling/ProfilingProjects/Profiles.tsx +++ b/src/components/Profiling/ProfilingProjects/Profiles.tsx @@ -24,7 +24,7 @@ import './profilingProjects.scss'; export default () => { const dispatch = useDispatch(); - const profiles = useSelector(getProfileProjects); + const projects = useSelector(getProfileProjects); const [showAddProjectDialog, setShowAddProjectDialog] = useState(false); useProfilingProjects(); @@ -73,7 +73,7 @@ export default () => {
- {profiles.map(project => ( + {projects.map(project => ( {project.error && ( diff --git a/src/components/Profiling/ProfilingProjects/useProfilingProjects.tsx b/src/components/Profiling/ProfilingProjects/useProfilingProjects.tsx index 1591ffb4..00986027 100644 --- a/src/components/Profiling/ProfilingProjects/useProfilingProjects.tsx +++ b/src/components/Profiling/ProfilingProjects/useProfilingProjects.tsx @@ -70,7 +70,7 @@ export const useProfilingProjects = () => { ) ); - const unsubscribe = recentProjects.map(recentProject => { + recentProjects.forEach(recentProject => { if (fs.existsSync(recentProject)) { const pathObject = path.parse(recentProject); try { @@ -80,19 +80,16 @@ export const useProfilingProjects = () => { name: pathObject.name, }); - // TODO See why no events come when file is changed - return store.onDidAnyChange(newSettings => { - dispatch( - updateProfilingProject({ - path: recentProject, - settings: newSettings ?? undefined, - error: - newSettings === undefined - ? 'fileMissing' - : undefined, - }) - ); - }); + dispatch( + updateProfilingProject({ + path: recentProject, + settings: store.store ?? undefined, + error: + store.store === undefined + ? 'fileMissing' + : undefined, + }) + ); } catch (error) { dispatch( updateProfilingProject({ @@ -101,9 +98,9 @@ export const useProfilingProjects = () => { error: 'fileCorrupted', }) ); - - return () => {}; } + + return; } dispatch( @@ -113,12 +110,6 @@ export const useProfilingProjects = () => { error: 'fileMissing', }) ); - - return () => {}; }); - - return () => { - unsubscribe.forEach(release => release()); - }; }, [dispatch, recentProjects]); }; diff --git a/src/features/nrfutillNpm/csvProcessing.ts b/src/features/nrfutillNpm/csvProcessing.ts index 2661483e..214e14af 100644 --- a/src/features/nrfutillNpm/csvProcessing.ts +++ b/src/features/nrfutillNpm/csvProcessing.ts @@ -211,7 +211,6 @@ export const generateParamsFromCSV = message: 'Processing has started', progress: 0, cancel: () => { - // TODO Ask for fix in NRF UTIL processCSV.kill('SIGINT'); dispatch( removeProjectProfileProgress({