From 77956d0f67e9b2b487419bf87fd316dbb396bf35 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 26 May 2025 19:33:35 +0530 Subject: [PATCH] Rename --- web/apps/photos/src/components/Export.tsx | 47 +++++++++---------- web/apps/photos/src/services/export/index.ts | 48 ++++++++++---------- 2 files changed, 45 insertions(+), 50 deletions(-) diff --git a/web/apps/photos/src/components/Export.tsx b/web/apps/photos/src/components/Export.tsx index 88a502bafc..0e58c5caf1 100644 --- a/web/apps/photos/src/components/Export.tsx +++ b/web/apps/photos/src/components/Export.tsx @@ -74,7 +74,7 @@ export const Export: React.FC = ({ failed: 0, total: 0, }); - const [pendingExports, setPendingExports] = useState([]); + const [pendingFiles, setPendingFiles] = useState([]); const [lastExportTime, setLastExportTime] = useState(0); // ==================== @@ -89,7 +89,7 @@ export const Export: React.FC = ({ setExportStage, setExportProgress, setLastExportTime, - setPendingExports, + setPendingFiles, }); const exportSettings: ExportSettings = exportService.getExportSettings(); @@ -131,17 +131,13 @@ export const Export: React.FC = ({ const syncExportRecord = async (exportFolder: string): Promise => { try { if (!(await exportService.exportFolderExists(exportFolder))) { - const pendingExports = - await exportService.getPendingExports(null); - setPendingExports(pendingExports); + setPendingFiles(await exportService.pendingFiles()); } const exportRecord = await exportService.getExportRecord(exportFolder); setExportStage(exportRecord.stage); setLastExportTime(exportRecord.lastAttemptTimestamp); - const pendingExports = - await exportService.getPendingExports(exportRecord); - setPendingExports(pendingExports); + setPendingFiles(await exportService.pendingFiles(exportRecord)); } catch (e) { if (e.message !== CustomError.EXPORT_FOLDER_DOES_NOT_EXIST) { log.error("syncExportRecord failed", e); @@ -215,7 +211,7 @@ export const Export: React.FC = ({ onHide={onClose} lastExportTime={lastExportTime} exportProgress={exportProgress} - pendingExports={pendingExports} + pendingFiles={pendingFiles} allCollectionsNameByID={allCollectionsNameByID} onStartExport={startExport} /> @@ -313,7 +309,7 @@ interface ExportDialogStageContentProps { onHide: () => void; lastExportTime: number; exportProgress: ExportProgress; - pendingExports: EnteFile[]; + pendingFiles: EnteFile[]; allCollectionsNameByID: Map; onStartExport: (opts?: ExportOpts) => void; } @@ -325,7 +321,7 @@ const ExportDialogStageContent: React.FC = ({ onHide, lastExportTime, exportProgress, - pendingExports, + pendingFiles, allCollectionsNameByID, }) => { switch (exportStage) { @@ -349,7 +345,7 @@ const ExportDialogStageContent: React.FC = ({ case ExportStage.finished: return ( ; onClose: () => void; @@ -485,7 +484,7 @@ interface ExportFinishedDialogContentProps { const ExportFinishedDialogContent: React.FC< ExportFinishedDialogContentProps > = ({ - pendingExports, + pendingFiles, lastExportTime, allCollectionsNameByID, onClose, @@ -502,13 +501,13 @@ const ExportFinishedDialogContent: React.FC< {t("pending_items")} - {pendingExports.length ? ( + {pendingFiles.length ? ( - {formattedNumber(pendingExports.length)} + {formattedNumber(pendingFiles.length)} ) : ( - {formattedNumber(pendingExports.length)} + {formattedNumber(pendingFiles.length)} )} @@ -538,7 +537,7 @@ const ExportFinishedDialogContent: React.FC< @@ -546,7 +545,7 @@ const ExportFinishedDialogContent: React.FC< }; type ExportPendingListDialogProps = ModalVisibilityProps & { - pendingExports: EnteFile[]; + pendingFiles: EnteFile[]; allCollectionsNameByID: Map; }; @@ -554,7 +553,7 @@ const ExportPendingListDialog: React.FC = ({ open, onClose, allCollectionsNameByID, - pendingExports, + pendingFiles, }) => { const renderListItem = (file: EnteFile) => { return ( @@ -581,11 +580,7 @@ const ExportPendingListDialog: React.FC = ({ }`; }; - const itemData = createItemData( - renderListItem, - getItemTitle, - pendingExports, - ); + const itemData = createItemData(renderListItem, getItemTitle, pendingFiles); const getItemKey: ListItemKeySelector> = (index, data) => { const { items } = data; @@ -594,7 +589,7 @@ const ExportPendingListDialog: React.FC = ({ }; const itemSize = 50; /* px */ - const itemCount = pendingExports.length; + const itemCount = pendingFiles.length; const listHeight = Math.min(itemCount * itemSize, 240); return ( diff --git a/web/apps/photos/src/services/export/index.ts b/web/apps/photos/src/services/export/index.ts index 527023a5cf..a7b6cdd9e5 100644 --- a/web/apps/photos/src/services/export/index.ts +++ b/web/apps/photos/src/services/export/index.ts @@ -89,7 +89,7 @@ interface ExportUIUpdaters { setExportStage: (stage: ExportStage) => void; setExportProgress: (progress: ExportProgress) => void; setLastExportTime: (exportTime: number) => void; - setPendingExports: (pendingExports: EnteFile[]) => void; + setPendingFiles: (pendingFiles: EnteFile[]) => void; } interface RequestCanceller { @@ -111,7 +111,7 @@ class ExportService { setExportProgress: () => {}, setExportStage: () => {}, setLastExportTime: () => {}, - setPendingExports: () => {}, + setPendingFiles: () => {}, }; private currentExportProgress: ExportProgress = { total: 0, @@ -223,22 +223,22 @@ class ExportService { } } - getPendingExports = async ( - exportRecord: ExportRecord, - ): Promise => { - try { - const files = await getAllLocalFiles(); - - const unExportedFiles = getUnExportedFiles( - files, - exportRecord, - undefined, - ); - return unExportedFiles; - } catch (e) { - log.error("getUpdateFileLists failed", e); - throw e; - } + /** + * Return the list of files that have not yet been exported. + * + * @param exportRecord The export record containing information about the + * export, including files which've been exported. If an export record is + * not specified (e.g. if the user has not exported anything yet and we just + * wish to show a preview of what will be exported), then the function will + * return the list of all files that will be exported if an export were to + * happen. + */ + pendingFiles = async (exportRecord?: ExportRecord): Promise => { + return getUnExportedFiles( + await getAllLocalFiles(), + exportRecord, + undefined, + ); }; async preExport(exportFolder: string) { @@ -262,11 +262,11 @@ class ExportService { } await this.updateExportStage(ExportStage.finished); await this.updateLastExportTime(Date.now()); - - const exportRecord = await this.getExportRecord(exportFolder); - - const pendingExports = await this.getPendingExports(exportRecord); - this.uiUpdater.setPendingExports(pendingExports); + this.uiUpdater.setPendingFiles( + await this.pendingFiles( + await this.getExportRecord(exportFolder), + ), + ); } catch (e) { log.error("postExport failed", e); } @@ -1329,7 +1329,7 @@ const readOnDiskFileExportRecordIDs = async ( */ const getUnExportedFiles = ( allFiles: EnteFile[], - exportRecord: ExportRecord, + exportRecord: ExportRecord | undefined, diskFileRecordIDs: Set | undefined, ) => { if (!exportRecord?.fileExportNames) {