Rename "scaled" to "compressed" when it comes to media attachments
This commit is contained in:
parent
1aff02c7d4
commit
90d5f3b2f8
4 changed files with 21 additions and 21 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue