fix: image compression checkbox now shows for all raster image types

The checkbox was only shown for image/jpeg and image/png. Users
uploading WebP, GIF, AVIF, BMP, TIFF, HEIC (iPhone photos) or any
other raster format never saw the checkbox at all.

Fix: isCompressible now checks file.type.startsWith('image/') and
excludes only image/svg+xml (vector — would rasterise) and empty type
strings. compressImage signature widened to File | Blob so it matches
the TUploadContent type without unsafe casts.

The send-path guard in handleSendUpload was also widened from the
hardcoded jpeg/png check to use isCompressible(), keeping the two gates
in sync. The Blob-safe id attribute uses the .name fallback so it
doesn't break when originalFile is a Blob without a name.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 20:22:38 -04:00
parent a78cb46bfe
commit 58b19995b8
3 changed files with 23 additions and 20 deletions
@@ -104,7 +104,7 @@ type CompressionCheckboxProps = {
setMetadata: (fileItem: TUploadItem, metadata: TUploadMetadata) => void;
};
function CompressionCheckbox({ fileItem, metadata, setMetadata }: CompressionCheckboxProps) {
const originalFile = fileItem.originalFile as File;
const originalFile = fileItem.originalFile as File | Blob;
const [compressing, setCompressing] = useState(false);
const compressPromiseRef = useRef<Promise<void> | null>(null);
@@ -136,6 +136,7 @@ function CompressionCheckbox({ fileItem, metadata, setMetadata }: CompressionChe
: null;
const originalSize = formatFileSize(originalFile.size);
const fileId = `compress-${(originalFile as File).name ?? ''}-${originalFile.size}`;
return (
<Box
@@ -152,14 +153,14 @@ function CompressionCheckbox({ fileItem, metadata, setMetadata }: CompressionChe
{/* Checkbox row */}
<Box alignItems="Center" gap="200">
<input
id={`compress-${originalFile.name}-${originalFile.size}`}
id={fileId}
type="checkbox"
checked={checked}
onChange={handleChange}
style={{ cursor: 'pointer', flexShrink: 0 }}
/>
<label
htmlFor={`compress-${originalFile.name}-${originalFile.size}`}
htmlFor={fileId}
style={{
cursor: 'pointer',
color: color.SurfaceVariant.OnContainer,