From 90d5f3b2f877a67cbe86448f4677f32353ef0096 Mon Sep 17 00:00:00 2001 From: N-Pex Date: Thu, 23 Oct 2025 10:19:37 +0200 Subject: [PATCH] Rename "scaled" to "compressed" when it comes to media attachments --- .../{ic_scaled.vue => ic_compressed.vue} | 0 src/components/file_mode/AttachmentInfo.vue | 16 +++++++-------- src/models/attachment.ts | 6 +++--- src/models/attachmentManager.ts | 20 +++++++++---------- 4 files changed, 21 insertions(+), 21 deletions(-) rename src/assets/icons/{ic_scaled.vue => ic_compressed.vue} (100%) diff --git a/src/assets/icons/ic_scaled.vue b/src/assets/icons/ic_compressed.vue similarity index 100% rename from src/assets/icons/ic_scaled.vue rename to src/assets/icons/ic_compressed.vue diff --git a/src/components/file_mode/AttachmentInfo.vue b/src/components/file_mode/AttachmentInfo.vue index 6710e75..c0f6f6a 100644 --- a/src/components/file_mode/AttachmentInfo.vue +++ b/src/components/file_mode/AttachmentInfo.vue @@ -1,19 +1,19 @@ diff --git a/src/models/attachment.ts b/src/models/attachment.ts index 36d7023..94e1c49 100644 --- a/src/models/attachment.ts +++ b/src/models/attachment.ts @@ -53,9 +53,9 @@ export type Attachment = { status: "loading" | "loaded"; file: File; dimensions?: { width: number; height: number }; - scaledFile?: File; - scaledDimensions?: { width: number; height: number }; - useScaled: boolean; + compressedFile?: File; + compressedDimensions?: { width: number; height: number }; + useCompressed: boolean; src?: string; proof?: Proof; mediaMetadata?: MediaMetadata; diff --git a/src/models/attachmentManager.ts b/src/models/attachmentManager.ts index 2b693e0..dda4fcf 100644 --- a/src/models/attachmentManager.ts +++ b/src/models/attachmentManager.ts @@ -56,7 +56,7 @@ export class AttachmentManager { let a: Attachment = { status: "loading", file: file, - useScaled: false, + useCompressed: false, sendInfo: { status: "initial", statusDate: 0, @@ -104,11 +104,11 @@ export class AttachmentManager { height: newHeight, outputType: "blob", }); - attachment.scaledFile = new File([compressedImg as BlobPart], file.name, { + attachment.compressedFile = new File([compressedImg as BlobPart], file.name, { type: "image/webp", lastModified: Date.now(), }); - attachment.scaledDimensions = { + attachment.compressedDimensions = { width: newWidth, height: newHeight, }; @@ -130,8 +130,8 @@ export class AttachmentManager { } return false; }; - attachment.useScaled = - attachment.scaledFile !== undefined && + attachment.useCompressed = + attachment.compressedFile !== undefined && (attachment.proof === undefined || !isDirectRoom(room) || attachment.proof.integrity === undefined || @@ -490,7 +490,7 @@ export const createUploadBatch = (manager: AttachmentManager | null, room: Room }; const isTooLarge = (attachment: Attachment) => { - const file = attachment.scaledFile && attachment.useScaled ? attachment.scaledFile : attachment.file; + const file = attachment.compressedFile && attachment.useCompressed ? attachment.compressedFile : attachment.file; return file.size > maxSizeUploads; }; @@ -608,11 +608,11 @@ export const createUploadBatch = (manager: AttachmentManager | null, room: Room item.sendInfo.status = "sending"; let file = (() => { - if (attachment.scaledFile && attachment.useScaled) { - // Send scaled version of image instead! - return attachment.scaledFile; + if (attachment.compressedFile && attachment.useCompressed) { + // Send compressed! + return attachment.compressedFile; } else { - // Send actual file image when not scaled! + // Send original return attachment.file; } })();