π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat(DownloadStatusNotification):for-single-video-show-progress
Aswin Asok424302717379
diff --git a/web/packages/gallery/components/DownloadStatusNotifications.tsx b/web/packages/gallery/components/DownloadStatusNotifications.tsxindex 109f8b171a..196c0cf636 100644--- a/web/packages/gallery/components/DownloadStatusNotifications.tsx+++ b/web/packages/gallery/components/DownloadStatusNotifications.tsx@@ -155,10 +155,9 @@ export const DownloadStatusNotifications: React.FC<const completedCount = group.success + group.failed;const progress =group.total === 1- ? `${t("processed_counts", {- count: completedCount,- total: group.total,- })} ${fileLabel}`+ ? group.progress === undefined+ ? undefined+ : `${group.progress}%`: t("download_progress", {count: completedCount,total: group.total,@@ -172,7 +171,7 @@ export const DownloadStatusNotifications: React.FC<}}>{statusText}- {!isComplete && (+ {!isComplete && progress !== undefined && (<>{" "}{"\u2022"} {progress}@@ -190,7 +189,10 @@ export const DownloadStatusNotifications: React.FC<<HugeiconsIcon icon={Tick02Icon} size={28} /></GlowingIconWrapper>);- } else if (isZipDownload && !group.isDownloadingZip) {+ } else if (+ group.total === 1 ||+ (isZipDownload && !group.isDownloadingZip)+ ) {startIcon = <SpinningIcon />;} else {startIcon = (diff --git a/web/packages/gallery/components/utils/save-groups.ts b/web/packages/gallery/components/utils/save-groups.tsindex 68c77fbd0e..b59e28db81 100644--- a/web/packages/gallery/components/utils/save-groups.ts+++ b/web/packages/gallery/components/utils/save-groups.ts@@ -11,6 +11,7 @@ export interface SaveGroup {total: number;success: number;failed: number;+ progress?: number;canceller: AbortController;failureReason?: "network_offline" | "file_error";includeZipNumber?: boolean;diff --git a/web/packages/gallery/services/download-core.ts b/web/packages/gallery/services/download-core.tsindex e10ffab533..105242df78 100644--- a/web/packages/gallery/services/download-core.ts+++ b/web/packages/gallery/services/download-core.ts@@ -29,6 +29,7 @@ export type RenderableSourceURLs =export interface FileDownloadOpts {background?: boolean;+ onProgress?: (progress: number) => void;}export interface DownloadManagerTransport {@@ -265,6 +266,7 @@ export class DownloadManagerCore {const onDownloadProgress = this.trackDownloadProgress(file.id,file.info?.fileSize,+ opts?.onProgress,);const contentLength =@@ -358,7 +360,9 @@ export class DownloadManagerCore {private trackDownloadProgress(fileID: number,fileSize: number | undefined,+ onProgress?: (progress: number) => void,) {+ let lastProgress: number | undefined;return (event: { loaded: number; total: number }) => {if (isNaN(event.total) || event.total === 0) {if (!fileSize) {@@ -366,14 +370,18 @@ export class DownloadManagerCore {}event.total = fileSize;}+ const progressValue = Math.round(+ (event.loaded * 100) / event.total,+ );const progress = new Map(this.fileDownloadProgress);if (event.loaded === event.total) {progress.delete(fileID);} else {- progress.set(- fileID,- Math.round((event.loaded * 100) / event.total),- );+ progress.set(fileID, progressValue);+ }+ if (progressValue !== lastProgress) {+ lastProgress = progressValue;+ onProgress?.(progressValue);}this.setFileDownloadProgress(progress);};diff --git a/web/packages/gallery/services/save-core.ts b/web/packages/gallery/services/save-core.tsindex 6eb9178332..baec08b304 100644--- a/web/packages/gallery/services/save-core.ts+++ b/web/packages/gallery/services/save-core.ts@@ -11,9 +11,10 @@ import type {AddSaveGroup,UpdateSaveGroup,} from "../components/utils/save-groups";+import type { FileDownloadOpts } from "./download-core";export interface BrowserSaveDownloader {- fileBlob(file: EnteFile): Promise<Blob>;+ fileBlob(file: EnteFile, opts?: FileDownloadOpts): Promise<Blob>;}export interface DownloadAndSaveFilesWebOpts {@@ -124,6 +125,7 @@ export const downloadAndSaveFilesWeb = async ({...g,failed: 0,failureReason: undefined,+ progress: undefined,}));failedFiles.length = 0;}@@ -154,7 +156,10 @@ export const downloadAndSaveFilesWeb = async ({singleFile.metadata.fileType !== FileType.livePhoto) {try {- const fileBlob = await downloader.fileBlob(singleFile);+ const fileBlob = await downloader.fileBlob(singleFile, {+ onProgress: (progress) =>+ updateSaveGroup((g) => ({ ...g, progress })),+ });const fileName = fileFileName(singleFile);const url = URL.createObjectURL(fileBlob);saveAsFileAndRevokeObjectURL(url, fileName);