π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat(DownloadStatusNotification):added-current-state-with-part-number
Aswin Asok8eab9931a03b
diff --git a/web/apps/photos/src/components/DownloadStatusNotifications.tsx b/web/apps/photos/src/components/DownloadStatusNotifications.tsxindex 30830bf9a1..4e589cccf3 100644--- a/web/apps/photos/src/components/DownloadStatusNotifications.tsx+++ b/web/apps/photos/src/components/DownloadStatusNotifications.tsx@@ -1,4 +1,5 @@import ReplayIcon from "@mui/icons-material/Replay";+import { Typography } from "@mui/material";import { useBaseContext } from "ente-base/context";import {isSaveComplete,@@ -8,6 +9,15 @@ import {import { Notification } from "ente-new/photos/components/Notification";import { t } from "i18next";+/** Maximum characters for album name before truncation */+const MAX_ALBUM_NAME_LENGTH = 20;++/** Truncate album name with ellipsis if it exceeds max length */+const truncateAlbumName = (name: string): string => {+ if (name.length <= MAX_ALBUM_NAME_LENGTH) return name;+ return name.slice(0, MAX_ALBUM_NAME_LENGTH) + "...";+};+interface DownloadStatusNotificationsProps {/*** A list of user-initiated downloads for which a status should be shown.@@ -101,6 +111,39 @@ export const DownloadStatusNotifications: React.FC<failedTitle = `${t("download_failed")} (${group.failed}/${group.total})`;}+ // Determine if this is a ZIP download (web with multiple files or live photo)+ const isZipDownload = !group.downloadDirPath && group.total > 1;+ const isDesktopOrSingleFile =+ !!group.downloadDirPath || group.total === 1;++ // Build the title based on download type+ let progressTitle: string;+ if (isZipDownload) {+ const part = group.currentPart ?? 1;+ progressTitle = group.isDownloadingZip+ ? t("downloading_part", { part })+ : t("preparing_part", { part });+ } else if (isDesktopOrSingleFile) {+ progressTitle =+ group.total === 1+ ? t("downloading_file")+ : t("downloading_files");+ } else {+ progressTitle = t("downloading");+ }++ // Build caption: "X / Y files - Album Name"+ const truncatedName = truncateAlbumName(group.title);+ const progress = t("download_progress", {+ count: group.success + group.failed,+ total: group.total,+ });+ const progressCaption = (+ <Typography variant="small" sx={{ color: "text.muted" }}>+ {progress} - {truncatedName}+ </Typography>+ );+return (<Notificationkey={group.id}@@ -115,15 +158,8 @@ export const DownloadStatusNotifications: React.FC<? failedTitle: isSaveComplete(group)? t("download_complete")- : group.downloadDirPath || group.total === 1- ? t("downloading_album", { name: group.title })- : t("creating_zip", { name: group.title }),- caption: isSaveComplete(group)- ? group.title- : t("download_progress", {- count: group.success + group.failed,- total: group.total,- }),+ : progressTitle,+ caption: isSaveComplete(group) ? group.title : progressCaption,onClick: createOnClick(group),endIcon: canRetry ? (<ReplayIcon titleAccess={t("retry")} />diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.jsonindex e6c761b151..cbd9c14938 100644--- a/web/packages/base/locales/en-US/translation.json+++ b/web/packages/base/locales/en-US/translation.json@@ -658,6 +658,12 @@"download_complete": "Download complete","downloading_album": "Downloading {{name}}","creating_zip": "Creating ZIP for {{name}}",+ "preparing": "Preparing",+ "downloading": "Downloading",+ "preparing_part": "Preparing Part {{part}}",+ "downloading_part": "Downloading Part {{part}}",+ "downloading_file": "Downloading file",+ "downloading_files": "Downloading files","download_failed": "Download failed","download_failed_network_offline": "Connection lost","download_failed_file_error": "Some files failed",diff --git a/web/packages/gallery/components/utils/save-groups.ts b/web/packages/gallery/components/utils/save-groups.tsindex d8861e6879..22a776bdf5 100644--- a/web/packages/gallery/components/utils/save-groups.ts+++ b/web/packages/gallery/components/utils/save-groups.ts@@ -82,6 +82,17 @@ export interface SaveGroup {* - undefined: No specific reason (generic error)*/failureReason?: "network_offline" | "file_error";+ /**+ * `true` when the ZIP file is being downloaded from memory to the user's+ * device. This is only relevant for web downloads where files are first+ * collected into a ZIP in memory, then saved to the device.+ */+ isDownloadingZip?: boolean;+ /**+ * The current ZIP part number being processed. Only relevant for web+ * downloads where files are batched into multiple ZIP parts.+ */+ currentPart?: number;}/**diff --git a/web/packages/gallery/services/save.ts b/web/packages/gallery/services/save.tsindex 449b9fd6ce..961bce84cb 100644--- a/web/packages/gallery/services/save.ts+++ b/web/packages/gallery/services/save.ts@@ -312,11 +312,18 @@ class ZipBatcher {private usedNames = new Set<string>();private baseName: string;private maxZipSize: number;-- constructor(baseName: string, maxZipSize: number, startingBatchIndex = 1) {+ private onStateChange?: (isDownloading: boolean, partNumber: number) => void;++ constructor(+ baseName: string,+ maxZipSize: number,+ startingBatchIndex = 1,+ onStateChange?: (isDownloading: boolean, partNumber: number) => void,+ ) {this.baseName = baseName;this.maxZipSize = maxZipSize;this.batchIndex = startingBatchIndex;+ this.onStateChange = onStateChange;}/**@@ -327,6 +334,13 @@ class ZipBatcher {return this.batchIndex;}+ /**+ * Get the current batch index being processed.+ */+ getCurrentBatchIndex(): number {+ return this.batchIndex;+ }+/*** Add file data to the current ZIP batch. If adding this file would exceed* the batch size limit, the current batch is downloaded first.@@ -341,6 +355,8 @@ class ZipBatcher {this.currentBatchSize + size > this.maxZipSize) {await this.downloadCurrentBatch();+ // Notify that we're now preparing a new part+ this.onStateChange?.(false, this.batchIndex);}// Ensure unique file names within the ZIP@@ -361,15 +377,20 @@ class ZipBatcher {}private async downloadCurrentBatch(): Promise<void> {- const zipBlob = await this.zip.generateAsync({ type: "blob" });- const fileLabel =- this.currentFileCount === 1- ? "1 file"- : `${this.currentFileCount} files`;- const zipName = `${this.baseName} Part ${this.batchIndex} - ${fileLabel}.zip`;-- const url = URL.createObjectURL(zipBlob);- saveAsFileAndRevokeObjectURL(url, zipName);+ this.onStateChange?.(true, this.batchIndex);+ try {+ const zipBlob = await this.zip.generateAsync({ type: "blob" });+ const fileLabel =+ this.currentFileCount === 1+ ? "1 file"+ : `${this.currentFileCount} files`;+ const zipName = `${this.baseName} Part ${this.batchIndex} - ${fileLabel}.zip`;++ const url = URL.createObjectURL(zipBlob);+ saveAsFileAndRevokeObjectURL(url, zipName);+ } finally {+ this.onStateChange?.(false, this.batchIndex);+ }// Reset for next batchthis.zip = new JSZip();@@ -463,7 +484,20 @@ const saveAsZip = async (startingBatchIndex = 1,): Promise<number> => {const { concurrency, maxZipSize } = getDownloadLimits();- const batcher = new ZipBatcher(baseName, maxZipSize, startingBatchIndex);+ const batcher = new ZipBatcher(+ baseName,+ maxZipSize,+ startingBatchIndex,+ (isDownloading, partNumber) =>+ updateSaveGroup((g) => ({+ ...g,+ isDownloadingZip: isDownloading,+ currentPart: partNumber,+ })),+ );++ // Set initial part number+ updateSaveGroup((g) => ({ ...g, currentPart: startingBatchIndex }));// Queue of files to processlet fileIndex = 0;