Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Merge main

laurenspriema470791c6c9a
diff --cc web/apps/ensu/src/pages/chat.tsx
index 6cc3cf7725,63e14fa79e..8d4cf9c29e
--- a/web/apps/ensu/src/pages/chat.tsx
+++ b/web/apps/ensu/src/pages/chat.tsx
@@@ -3570,30 -3616,37 +3632,41 @@@ const Page: React.FC = () =>
handleImageCancel();
return;
}
+ const pathsToProcess = selectedPaths.slice(
+ 0,
+ imageAttachmentSlotsRemaining,
+ );
- const { invoke } = await import("@tauri-apps/api/tauri");
- const files = await Promise.all(
- pathsToProcess.map(async (selectedPath) => {
- const normalized = selectedPath.replace(/\\/g, "/");
- const name =
- normalized.split("/").pop()?.replace(/\0/g, "") ||
- "image";
- const compressed = await invoke<number[]>(
- "chat_db_compress_attachment_image_file",
- { path: selectedPath },
- );
- const bytes = new Uint8Array(compressed);
- return new File(
- [toSafeBlobPart(bytes)],
- normalizedJpegAttachmentName(name),
- { type: "image/jpeg" },
- );
- }),
- );
+ let files: File[];
+ try {
+ const { invoke } = await import("@tauri-apps/api/tauri");
+ files = await Promise.all(
- selectedPaths.map(async (selectedPath) => {
++ pathsToProcess.map(async (selectedPath) => {
+ const normalized = selectedPath.replace(/\\/g, "/");
+ const name =
+ normalized.split("/").pop()?.replace(/\0/g, "") ||
+ "image";
+ const compressed = await invoke<number[]>(
+ "chat_db_compress_attachment_image_file",
+ { path: selectedPath },
+ );
+ const bytes = new Uint8Array(compressed);
+ return new File(
+ [toSafeBlobPart(bytes)],
+ normalizedJpegAttachmentName(name),
+ { type: "image/jpeg" },
+ );
+ }),
+ );
+ } catch (error) {
+ log.error(
+ `Failed to process selected image attachment: ${formatImageProcessingErrorForLog(error)}`,
+ );
+ showMiniDialog(
- imageProcessingFailureDialog(error, selectedPaths.length),
++ imageProcessingFailureDialog(error, pathsToProcess.length),
+ );
+ return;
+ }
log.info("Compressed selected image attachments", {
count: files.length,