Skip to content

armgit / VERT

Public Imported from GitHub
0

The next-generation file converter. Open source, fully local* and free forever.

feat: feedback for downloading zip

Mayae01c7a4fdef8
diff --git a/messages/en.json b/messages/en.json
index 3df9e3d..3cc258d 100644
--- a/messages/en.json
+++ b/messages/en.json
@@ -70,6 +70,7 @@
"panel": {
"convert_all": "Convert all",
"download_all": "Download all as .zip",
+ "download_all_toast": "Zipping {count} files ({size}MB) for download. This may take a while for larger files (which may be streamed).",
"remove_all": "Remove all files",
"set_all_to": "Set all to",
"na": "N/A"
diff --git a/src/lib/store/index.svelte.ts b/src/lib/store/index.svelte.ts
index 54b5a89..0bc9611 100644
--- a/src/lib/store/index.svelte.ts
+++ b/src/lib/store/index.svelte.ts
@@ -400,6 +400,7 @@ class Files {
public async downloadAll() {
if (this.files.length === 0) return;
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const dlFiles: any[] = [];
const filenames: string[] = [];
@@ -419,6 +420,8 @@ class Files {
filenames.push(file.file.name.replace(/\.[^/.]+$/, "") + to);
}
+ let totalSize = 0;
+
for (let i = 0; i < this.files.length; i++) {
const file = this.files[i];
const result = file.result;
@@ -437,6 +440,7 @@ class Files {
filename = `${nameWithoutExt} (${i + 1})${ext}`;
}
+ totalSize += result.file.size;
dlFiles.push({
name: filename,
lastModified: Date.now(),
@@ -445,7 +449,20 @@ class Files {
}
const { downloadZip } = await import("client-zip");
+ const size = (totalSize / (1024 * 1024)).toFixed(2);
+ log(
+ ["files"],
+ `adding ${dlFiles.length} files into zip (size: ${size}MB)...`,
+ );
+ ToastManager.add({
+ type: "info",
+ message: m["convert.panel.download_all_toast"]({
+ count: dlFiles.length,
+ size,
+ }),
+ });
const blob = await downloadZip(dlFiles, "converted.zip").blob();
+
const url = URL.createObjectURL(blob);
const settings = readSettings<{ filenameFormat?: string }>();