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
|
|
@ -1,19 +1,19 @@
|
|||
<template>
|
||||
<div class="attachment-info">
|
||||
<div v-if="attachment.scaledFile" class="attachment-info__quality">
|
||||
<div v-if="attachment.compressedFile" class="attachment-info__quality">
|
||||
<div class="attachment-info__quality__title">
|
||||
{{ t("file_mode.quality") }}
|
||||
</div>
|
||||
<div class="d-flex justify-center">
|
||||
<div @click="attachment.useScaled = true" :class="{ 'attachment-info__quality__class': true, selected: attachment.useScaled, clickable: true }">
|
||||
<v-icon>$vuetify.icons.ic_scaled</v-icon>
|
||||
<div @click="attachment.useCompressed = true" :class="{ 'attachment-info__quality__class': true, selected: attachment.useCompressed, clickable: true }">
|
||||
<v-icon>$vuetify.icons.ic_compressed</v-icon>
|
||||
<div class="attachment-info__quality__class-name">{{ t("file_mode.compressed") }}</div>
|
||||
<div class="attachment-info__quality__class-size">
|
||||
<span>{{ attachment.scaledDimensions?.width }} x {{ attachment.scaledDimensions?.height }}</span>
|
||||
<span> ({{ formatBytes(attachment.scaledFile.size) }})</span>
|
||||
<span>{{ attachment.compressedDimensions?.width }} x {{ attachment.compressedDimensions?.height }}</span>
|
||||
<span> ({{ formatBytes(attachment.compressedFile.size) }})</span>
|
||||
</div>
|
||||
</div>
|
||||
<div @click="attachment.useScaled = false" :class="{ 'attachment-info__quality__class': true, selected: !attachment.useScaled, clickable: true }">
|
||||
<div @click="attachment.useCompressed = false" :class="{ 'attachment-info__quality__class': true, selected: !attachment.useCompressed, clickable: true }">
|
||||
<v-icon>$vuetify.icons.ic_original</v-icon>
|
||||
<div class="attachment-info__quality__class-name">{{ t("file_mode.original") }}</div>
|
||||
<div class="attachment-info__quality__class-size">
|
||||
|
|
@ -24,11 +24,11 @@
|
|||
</div>
|
||||
|
||||
<div class="attachment-info__quality__info">
|
||||
{{ t(attachment.useScaled ? "file_mode.metadata_info_compressed" : "file_mode.metadata_info_original") }}
|
||||
{{ t(attachment.useCompressed ? "file_mode.metadata_info_compressed" : "file_mode.metadata_info_original") }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<C2PAInfo class="attachment-info__detail-box" v-if="showC2PAInfo || hasExif" :proof="attachment.proof" :metadata="attachment.mediaMetadata" :showFlagsOnly="attachment.useScaled" />
|
||||
<C2PAInfo class="attachment-info__detail-box" v-if="showC2PAInfo || hasExif" :proof="attachment.proof" :metadata="attachment.mediaMetadata" :showFlagsOnly="attachment.useCompressed" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -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