From 250829ba457759247c0217c5d0b0cb4c6fb4f0f4 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Fri, 29 Aug 2025 16:20:14 +0200 Subject: [PATCH] add logging when saving #2496 --- src/renderer/src/edlStore.ts | 8 ++++---- src/renderer/src/hooks/useSegmentsAutoSave.ts | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/renderer/src/edlStore.ts b/src/renderer/src/edlStore.ts index 4a07c484..66428774 100644 --- a/src/renderer/src/edlStore.ts +++ b/src/renderer/src/edlStore.ts @@ -81,14 +81,14 @@ export async function saveSrt(path: string, cutSegments: SegmentBase[]) { await writeFile(path, formatSrt(cutSegments)); } -export async function saveLlcProject({ savePath, filePath, cutSegments }: { +export async function saveLlcProject({ savePath, mediaFilePath, cutSegments }: { savePath: string, - filePath: string, + mediaFilePath: string, cutSegments: StateSegment[], }) { const projectData: LlcProject = { version: 2, - mediaFileName: basename(filePath), + mediaFileName: basename(mediaFilePath), cutSegments: mapSaveableSegments(cutSegments), }; await writeFile(savePath, JSON5.stringify(projectData, null, 2)); @@ -222,6 +222,6 @@ export async function exportEdlFile({ type, cutSegments, customOutDir, filePath, else if (type === 'tsv-human') await saveTsv(savePath, cutSegments); else if (type === 'csv-human') await saveCsvHuman(savePath, cutSegments); else if (type === 'csv-frames') await saveCsvFrames({ path: savePath, cutSegments, getFrameCount }); - else if (type === 'llc') await saveLlcProject({ savePath, filePath, cutSegments }); + else if (type === 'llc') await saveLlcProject({ savePath, mediaFilePath: filePath, cutSegments }); else if (type === 'srt') await saveSrt(savePath, cutSegments); } diff --git a/src/renderer/src/hooks/useSegmentsAutoSave.ts b/src/renderer/src/hooks/useSegmentsAutoSave.ts index 00254e53..1f0dd7a1 100644 --- a/src/renderer/src/hooks/useSegmentsAutoSave.ts +++ b/src/renderer/src/hooks/useSegmentsAutoSave.ts @@ -29,6 +29,7 @@ export default ({ autoSaveProjectFile, storeProjectInWorkingDir, filePath, custo return { cutSegments, projectFileSavePath, filePath }; }, [cutSegments, filePath, projectFileSavePath]); + // NOTE: Could lose a save if user closes too fast, but not a big issue I think const [debouncedSaveOperation] = useDebounce(currentSaveOperation, isDev ? 2000 : 500); const lastSaveOperation = useRef(); @@ -36,7 +37,6 @@ export default ({ autoSaveProjectFile, storeProjectInWorkingDir, filePath, custo useEffect(() => { async function save() { try { - // NOTE: Could lose a save if user closes too fast, but not a big issue I think if (!autoSaveProjectFile || !debouncedSaveOperation || debouncedSaveOperation.filePath == null @@ -49,7 +49,8 @@ export default ({ autoSaveProjectFile, storeProjectInWorkingDir, filePath, custo return; } - await saveLlcProject({ savePath: debouncedSaveOperation.projectFileSavePath, filePath: debouncedSaveOperation.filePath, cutSegments: debouncedSaveOperation.cutSegments }); + console.log('Saving project file', debouncedSaveOperation.projectFileSavePath, debouncedSaveOperation.cutSegments); + await saveLlcProject({ savePath: debouncedSaveOperation.projectFileSavePath, mediaFilePath: debouncedSaveOperation.filePath, cutSegments: debouncedSaveOperation.cutSegments }); lastSaveOperation.current = debouncedSaveOperation; } catch (err) { errorToast(i18n.t('Unable to save project file'));