From 3db3241ccd6551470976fec17a98c42fac3300f3 Mon Sep 17 00:00:00 2001 From: Michael Yaworski Date: Sun, 14 Nov 2021 10:03:45 -0500 Subject: [PATCH] Remove deleted files from batch (#861) * Remove deleted files from batch * improve a bit Co-authored-by: Mikael Finstad --- src/App.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/App.jsx b/src/App.jsx index 788fecce..685c6e15 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -959,6 +959,8 @@ const App = memo(() => { setBatchFiles([]); }, [askBeforeClose]); + const removeBatchFile = useCallback((path) => setBatchFiles((existingBatch) => existingBatch.filter((existingFile) => existingFile.path !== path)), []); + const cleanupFiles = useCallback(async () => { // Because we will reset state before deleting files const saved = { previewFilePath, filePath, edlFilePath }; @@ -978,6 +980,8 @@ const App = memo(() => { if (workingRef.current) return; + removeBatchFile(saved.filePath); + try { setWorking(i18n.t('Cleaning up')); @@ -1008,7 +1012,7 @@ const App = memo(() => { } finally { setWorking(); } - }, [filePath, previewFilePath, closeFile, edlFilePath, cleanupChoices, setWorking]); + }, [previewFilePath, filePath, edlFilePath, closeFile, cleanupChoices, removeBatchFile, setWorking]); const outSegments = useMemo(() => (invertCutSegments ? inverseCutSegments : apparentCutSegments), [invertCutSegments, inverseCutSegments, apparentCutSegments]);