diff --git a/web/apps/photos/src/components/Export.tsx b/web/apps/photos/src/components/Export.tsx index 9cd5c38105..17bfa6b6c7 100644 --- a/web/apps/photos/src/components/Export.tsx +++ b/web/apps/photos/src/components/Export.tsx @@ -164,15 +164,17 @@ export const Export: React.FC = ({ // UI functions // ============= - const handleChangeExportDirectoryClick = async () => { - const newFolder = await selectAndPrepareExportDirectory(); - if (!newFolder) return; + const handleChangeExportDirectory = useCallback(() => { + void (async () => { + const newFolder = await selectAndPrepareExportDirectory(); + if (!newFolder) return; - log.info(`Export folder changed to ${newFolder}`); - exportService.updateExportSettings({ folder: newFolder }); - setExportFolder(newFolder); - await syncExportRecord(newFolder); - }; + log.info(`Export folder changed to ${newFolder}`); + exportService.updateExportSettings({ folder: newFolder }); + setExportFolder(newFolder); + await syncExportRecord(newFolder); + })(); + }, [syncExportRecord]); const toggleContinuousExport = async () => { if (!(await verifyExportFolderExists())) return; @@ -215,7 +217,7 @@ export const Export: React.FC = ({ = ({ ); }; -function ExportDirectory({ exportFolder, changeExportDirectory, exportStage }) { - return ( - - - {t("destination")} - - {exportFolder ? ( - <> - - {exportStage === ExportStage.finished || - exportStage === ExportStage.init ? ( - - ) : ( - // Prevent layout shift. - - )} - - ) : ( - - )} - - ); +interface ExportDirectoryProps { + exportStage: ExportStage; + exportFolder: string; + onChangeExportDirectory: () => void; } +const ExportDirectory: React.FC = ({ + exportStage, + exportFolder, + onChangeExportDirectory, +}) => ( + + + {t("destination")} + + {exportFolder ? ( + <> + + {exportStage === ExportStage.finished || + exportStage === ExportStage.init ? ( + + ) : ( + // Prevent layout shift. + + )} + + ) : ( + + )} + +); + const DirectoryPath = ({ path }) => ( void ensureElectron().openDirectory(path)}>